On Fri, Aug 13, 2010 at 2:44 PM, David Bruce <davidstuartbr...@gmail.com> wrote:
> Hi,
>
> Along these lines, we are in a somewhat similar situation.  Basically,
> we have had a major feature branch for a GSoC project, and this branch
> has now substantially diverged from master.  However, the divergence
> is almost completely due to equivalent work that was done first in
> master, and then re-done "by hand" in the feature branch because it
> was too hard to merge (we are git noobs).  So, we want to make master
> point to the new branch, and rename master to something like
> old_master for safekeeping.  So it looks like we should first create a
> branch (or tag) to save the tip of master, and then hard reset master
> to the tip of the feature branch.
>

If it's just a local repository (probably not) you can just rename the
branches, I'll use the branch name dev_branch to stand in for your
feature branch:

git branch -m master old_master
git branch -m dev_branch master

If the branches are remote you should be able to rename and end up
with tracking branches with something like this:

First rename the current master branch

git push origin master:refs/heads/old_master
           Create the branch old_master in the origin repository by
copying the current master branch.
git fetch origin
           Fetch updates from the remote repository
git branch --track old_master origin/old_master
           create a tracking branch
git checkout old_master
git push origin :refs/heads/master
            Delete the remote master branch, remember that a branch is
just a pointer to a commit, and deleting it doesn't delete the commit
or any other commits
git branch -d master
            Delete the local master branch

Now rename the dev_branch to be the new master branch:
git checkout dev_branch
git push origin master:refs/heads/dev_branch
git fetch origin
git branch -track master origin/master
git checkout master
git push origin :refs/heads/dev_branch
git branch -d dev_branch

The last two steps (which delete the remote and local dev_branch are optional)

There may be more efficient ways to do this. I use the grb ruby gem to
handle tasks like this and this is how it approaches renaming a remote
branch.


-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.

Reply via email to