Gimme gimme yoink9/20/2023 Next, it checks out your main branch and pulls the latest contents. It also saves "untracked" / new files with the -u flag. It assumes you might not be on the main branch just yet, so it'll stash everything you're working on using the stash command. This is my "return to home base" command. gimme ✊ alias gimme = "git stash push -u & git checkout main & git pull -r" ✋ But wait! Before you blindly copy these, let's unpack each of them a little. And for all you windows users out there: you'll probably need to install the Git Bash terminal (included with Git) and create the file like so. So if you want to use these in your own terminal, go find your bashrc and paste away! This is usually found in your user directory: ~/.bashrc. Here's my 4 shortcuts for slamming through daily tasks □ # Stash what I'm working on and checkout the latest master alias gimme = "git stash push -u & git checkout main & git pull -r" # Grab the latest master and come back to the branch I was on (with stashing!) alias yoink = "gimme & git checkout - & git stash pop" # Checkout a new branch and push it to origin (so I don't forget that set-upstream) woosh ( ) # ALL TOGETHER NOW # Stash my current WIP, checkout a new branch off the latest master, and push it to origin alias boop = "gimme & woosh" □ Writing aliases for your terminal to tie it all togetherĪlright, let's do the big reveal. □ The importance of pushing and popping your stash You know you cringe a little every time this pops up □ Git push -set-upstream origin crap-not-again But when I'm hurrying, it's so easy to either a) work off an old "main" branch, or b) do the copy-paste of shame before your PR: To push the current branch and set the remote as upstream, use I'll probably do this 5+ times in one day if we're in a bug-squashing flow. I need to push that branch to origin before opening my PR.Stop me if you've seen this workflow before: Naturally, I started automating the workflows I use day-in and day-out □ I started my first full-time job as a programmer this year, which means I've been picking up a lot of new tricks in a pretty quick timeframe.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |