How to practice not freaking out when you see (master|MERGING) by using git merge –abort – 102

I feel that a lot of Git tutorials forget what that raw, primal panic feels like when you see your branch name change to (master|MERGING). For me personally, 80% of the panic comes from not knowing “how do I get out of this state?! How can we pretend this never happened??”

Today’s tip is about how to get into and out of a merge conflict state, without creating any actual conflicts! I say no conflicts because the easier the setup, the easier it will be to practice, and eventually you’ll build up enough muscle memory to stay calm in future situations.

I have a branch called mybranch3 that simply contains a new file (e.g. touch myfile.txt). If I did just a `git merge –no-commit mybranch3` git would apply a fast-forward, so you have to add the –no-ff. I guess the fast-forward check take precedence in the git world. 

The –no-commit tells Git not to automatically do a merge commit, but rather, let you manually do the merge commit, as we’ll see in tomorrow’s tip.

git merge --no-ff --no-commit mybranch3

You could do a `git status` to figure out how to finish the merge (e.g. `git commit -m “merging mybranch3″`), but today’s tip is about practicing, “I’m taking my ball and going home.” You show Git who’s boss!

You’ll want to run the command `git merge –abort`

git merge --abort

and as you see from the `git log –oneline`, nothing was merged in from mybranch3. (the readme commit was my initial commit. I guess saying initial commit would have made more sense.)

P.S. this was my original vision for this series: take each option of each git command, play with it, try to break it, and blog about it. And it’s still my vision! But got to get through some of the more conceptual stuff first. I also want to get to the internal plumbing of trees, blobs, etc. Maybe in December 😉

Leave a comment