Keeping linear history when pulling
suggest changeRebasing when pulling
If the remote branch has new commits and you also have local commits, git pull merges them. To replay your local commits on top of the remote branch instead:
git pull --rebase
Making it the default behavior
To make this the default behavior for newly created branches, type the following command:
git config branch.autosetuprebase always
To change the behavior of an existing branch, use this:
git config branch.BRANCH_NAME.rebase true
And
git pull --no-rebase
To perform a normal merging pull.
Check if fast-forwardable
To only allow fast forwarding the local branch, you can use:
git pull --ff-only
This fails when your local commits and the remote commits have diverged, so the update is not a fast-forward. Rebase or merge before you pull again. Uncommitted work can also stop the pull.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents