Avoiding Git Merge Commits with branch.branchname.rebase = true

If you have local changes in your Git repo and pull in new changes from your remote repository, Git will per default create a merge commit for the pulled changes. This can clutter your history with unnecessary commits.

To rebase your local changes on top of the pulled changes, you can use:

git pull --rebase

To activate this for all new branches.

git config --global branch.autosetuprebase always

To update existing branches in your Git repo use the command:

git config branch.<name>.rebase true

Not everyone likes rebase. Here is a little summary why Linus Torvalds doesn’t like rebasing: http://kerneltrap.org/Linux/Git_Management.

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of vogella.com. With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Other and tagged . Bookmark the permalink.

2 Responses to Avoiding Git Merge Commits with branch.branchname.rebase = true

Comments are closed.