Rebasing reapplies a series of commits on top of another commit.
To rebase
a branch, checkout the branch and then rebase
it on top of another branch.
git checkout topic
git rebase master # rebase current branch onto master branch
This would cause:
A---B---C topic
/
D---E---F---G master
To turn into:
A'--B'--C' topic
/
D---E---F---G master
These operations can be combined into a single command that checks out the branch and immediately rebases it:
git rebase master topic # rebase topic branch onto master branch
Important: After the rebase, the applied commits will have a different hash. You should not rebase commits you have already pushed to a remote host. A consequence may be an inability to git push
your local rebased branch to a remote host, leaving your only option to git push --force
.