git pull --rebase

I used to really hate my commit history because it was scattered with Foxtrot merges.

Foxtrot Merge

The image above (from Atlassian's blog) explains what it is - you end up with an extra commit in your history that usually says something like "Merge" or "Merge origin/master into..."

Nobody needs that commit that contributes nothing and it just clutters the history if your software.

Solution: git pull --rebase

Most git users know git pull and git rebase, but usage of git pull --rebase is less widespread.

Fixing this problem is simple: use git pull --rebase instead of git pull - ALWAYS.

What's the difference?

git pull merges any remote changes when it pulls them down

git rebase replays changes on one branch to another

git pull --rebase replays local changes onto remote changes


Here's a live example of the problem and solution. You'll notice that the git pull --rebase version puts the local change after the remote change even though the local change was technically made before the local change. A somewhat unlikely scenario, but if it happens is a small price to pay for a cleaner git log.

Jeffrey Fate