After reading several articles and tutorials on Git rebasing, I was left without some critical context when working on a shared project. Several times, I was left with a tangled commit graph when rebasing on an outdated master branch or trying to push my rebased branch to GitHub. Below, is the full-flow rebase example that I am not using, thanks to help from my friend and colleague Toni Ala-Piirto.
Note: This example assumes we are working in a shared remote named origin, and we are rebasing the master branch into our feature-branch.
- make sure the local
masterbranch is up-to-date with the latest remote changesgit checkout master && git pull origin master
- checkout
feature branchgit checkout feature-branch
- rebase and resolve any conflicts that arise
git rebase master
-
force push the rebased branch to the remote (
originin this case)git push --force-with-lease
For a bit more information about the --force-with-lease flag, see the StackOverflow question git push --force-with-lease vs. --force.
![]()
This work is licensed under a Creative Commons Attribution 4.0 International License.
Top comments (0)