Skip to content

Instantly share code, notes, and snippets.

@cliftonlabrum
Created March 1, 2013 20:28
Show Gist options
  • Save cliftonlabrum/5067512 to your computer and use it in GitHub Desktop.
Save cliftonlabrum/5067512 to your computer and use it in GitHub Desktop.
Doing a Git Pull with a Rebase instead of a Merge
Pull with rebase instead of merge
$ git pull --rebase
# e.g. if on branch "master": performs a `git fetch origin`,
# then `git rebase origin/master`
Because branch merges in git are recorded with a merge commit, they are supposed to be meaningful—for example, to indicate when a feature has been merged to a release branch. However, during a regular daily workflow where several team members sync a single branch often, the timeline gets polluted with unnecessary micro-merges on regular git pull. Rebasing ensures that the commits are always re-applied so that the history stays linear.
You can configure certain branches to always do this without the --rebase flag:
# make `git pull` on master always use rebase
$ git config branch.master.rebase true
You can also set up a global option to set the last property for every new tracked branch:
# setup rebase for every tracking branch
$ git config --global branch.autosetuprebase always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment