DEV Community

Brylie Christopher Oxley
Brylie Christopher Oxley

Posted on

4

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.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay