-
Notifications
You must be signed in to change notification settings - Fork 4
How to rebase
SpechtMagnus edited this page Nov 18, 2019
·
1 revision
git pull --rebase
Use this command for every pull or set your default pull behavior to rebase. This can be achieved via
git config --global pull.rebase true
Or simply add an alias to your ~/.bashrc
(Linux only)
git fetch
git rebase origin/master
After this the history of the local branch will be different from the history of the remote branch so you have to push with force. Use force-with-lease
to only override known changes. (i.e. avoid overriding changes that someone pushed after your last pull/fetch)
git push --force-with-lease
git fetch origin
git reset --hard
WARNING This will remove all commits that were not on the remote branch!
To save your local commits you have to rebase them onto the remote branch using the last pushed commit.
git tag temp-base [ID of the last commit that has already been pushed]
git fetch
git rebase temp-base [branch-name] --onto origin/[branch-name]
git tag -d temp-base