Git pull and autostash
git stash a lot. Like, really a lot. Probably more than you should. It’s just a really neat way to keep your changes somewhere while jumping around between branches, e.g. because you have to QA changes from collegues or just quickly want to confirm how things were working in another branch.
Another thing I use
stash for is when pulling in latest changes from origin without having to commit my changes just yet. It’s as easy as this:
git stash pop
In the end you either end up with your changes applied on top of latest origin, or you get appropriate conflicts you need to resolve if you and the origin changed the same code.
This is easy and straight forward, but it’s still 3 individual steps to do whenever I want to perform this action, which just adds up over time. So when I found this on twitter today it absolutely made my day:
git tip:— Tejas Kumar (@TejasKumar_) July 12, 2019
if you've been frustrated by not being able to pull or rebase because you have existing changes,
say hello to my little friend:
`git pull --autostash` pic.twitter.com/gDutlj5A3m
Being able to do all the stashing logic with one git command is just nice. Not solving the biggest problem in the world here, but I think it was neat and I’m definitely gonna use it a lot moving forward 😄