Fast and simple tip to increase your Git Fu level.

TL;DR, run the following code in your terminal and be happy:

git config --global rerere.enabled 1

Explaining: Git rerere (reuse recorded resolution) is a hidden Git feature which, as the name says, allow record and reuse previous conflicts resolutions.

Let's say you are working in a feature-a branch, created from master branch. Some time later, you discover your colleague made some changes in master that can lead to a conflict with your feature-a code.

So, to make sure your new feature will still work when are ready, you go to the new master branch and try to merge your feature-a branch. As expected, you got some conflicts between the two branchs. So you solve them right now, as your new code is still fresh in your mind, and conclude the merge.





Sometimes is not so easy.



But there's a problem, the feature-a isn't ready, so you can't push it to master now. So, after doing your tests, you discard the merge you just have made and go back to work on feature-a.

Generally, this means you are discarding your conflicts resolutions too, then later, when you are ready to merge feature-a definitively, you'll must solve the conflicts again. That's when enters Git rerere.

Git rerere records the changes you made to resolve a given conflict and can reapply it later, when you get the same conflict again. To use it, you must run the command git rerere every time you finish resolving a conflict, before doing the resolved merge commit (it works with rebase too!).

But you can make you life easy. With the command from the first lines of the article you enable Git rerere to run automatically every time you resolve some conflict during a merge. The resolution will be saved and, when you got the same conflict again, it'll be applied automatically, so you just need to review it and make the final commit if everything is ok.

Git rerere is a feature to enable and forget it's exists, it'll be ready to do its job just when you need it.