Fixing a Git Branch that Started in the Wrong Place

21 May 2012

Today I did some work on a branch in git only to discover that I based it on some unstable code rather than the stable code that I usually want to use as a baseline.

You can fix this by using a bit of git’s rebase magic:

git rebase --onto master testing

This moves the entire current branch onto another.

2 Responses to “Fixing a Git Branch that Started in the Wrong Place”

  1. hspencer77 Says:

    Reblogged this on More Mind Spew-age from Harold Spencer Jr. and commented:
    Some good Git work. Good explanation on how to get out of a tricky situation. Thanks!

  2. pixelbeat1 Says:

    This is a useful technique when using git to manage a patch set that’s rebased on a changing upstream, as described in II.2 in the following URL

    http://pkgs.fedoraproject.org/gitweb/?p=openstack-nova.git;a=blob_plain;f=update-patches.txt;hb=HEAD

    http://pkgs.fedoraproject.org/gitweb/?p=openstack-nova.git;a=blob;f=update-patches.sh;hb=HEAD


Comments are closed.