DEV Community

Brylie Christopher Oxley
Brylie Christopher Oxley

Posted on

Full Git rebase flow for a busy remote

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.

  1. make sure the local master branch is up-to-date with the latest remote changes
    • git checkout master && git pull origin master
  2. checkout feature branch
    • git checkout feature-branch
  3. rebase and resolve any conflicts that arise
    • git rebase master
  4. force push the rebased branch to the remote (origin in 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.


Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

Top comments (0)