

Think of this like throwing all your belongings in a bag, and git stash apply is like dumping everything out onto the floor.

This is the simplest command of the bunch, but it's also my most-used! On my team, we run a lot of automated scripts on pull for installing dependencies and pulling content from our CMS. That -r flag will be sure to "rebase" onto the latest, preventing unecessary merge conflicts. 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.
Yoink definition install#
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.
