Thursday, February 12, 2015

Git Rebase

Rebase when you've been on a branch for a few days and you know there have been changes to master.

That way, when you do push your branch up for a pull request and code review it can be easily merged in with the master branch.

Assuming you're on my-feature-branch...

Rebase Commands

git checkout master
git pull
git checkout my-feature-branch
git rebase master
git push -f


Be sure to run git push -f, not what git is likely to suggest after you run the git rebase master command (git pull).

If you do have the misfortune of pulling changes into the rebase work you did, then you'll end up with a bunch of recent commits to the master branch, that you've already accounted for, in your pull request...

...and you will likely need to delete that branch and recreate it by cherry picking the commits you need.


Share this article

This work is licensed under the Creative Commons Attribution 3.0 Unported License.

1 comment:

  1. CA Siteminder CA Siteminder Training "
    CA Siteminder Online Training
    Send ur Enquiry to
    21st Century SiteMinder Training Synopsis:
    Through a combination of presentations and hands-on lab work, the students will go through a complete SiteMinder implementation project, including installation, configuration, deploying agents, protecting applications, maintaining, and troubleshooting." more… Online Training- Corporate Training- IT Support U Can Reach Us On +917386622889 - +919000444287