Continuing my series of useful Git stuff, here are a few useful one-liners that can make life easier.
Recovering from bad reset
Imagine for instance that you just pulled master into your own branch but realized you should have rebased instead to avoid those pesky merge commits. Imagine also that you wanted to recover by doing a
git reset --hard, but you accidentally killed some of your own commits too. It may look like you are screwed now, but all is not lost – git still knows about your commits. Use
git reflog to see the commits again and merge them back as needed. If you have just killed a single commit, the easiest way to get it back is with
git cherry-pick ORIG_HEAD. Handy.
Setting up proper remote tracking
You are using Arcanist in your project, and created a feature branch with
arc branch, then it looks like remote tracking has been set up, but your feature branch is actually tracking master. Probably not what you want. To fix this, run
git branch --set-upstream