tags:

views:

333

answers:

2

We've already learned how to switch which branch points to what using git branch -m. If I do this, is it going to make life difficult for the other people pulling from my repository?

Say I do a bunch of stuff on a branch topic1 and then do a

git branch -m master old_master
git branch -m topic1 master
git push origin master

and then somebody else pulls master from the my remote repository, what will they have to do to make everything point to the right place? Will I have to tell everybody to repeat my steps?

Is this akin to the problem of rebasing commits after pushing them and leaving other developers with dangling objects?

A: 

Basically your operations are the same as:

# git checkout master
# git reset --hard topic1
# git push origin master

And they will have exactly that effect: Everybody else will get the topic1 branch (it’s named master for them, though) and its ancestry up to the point where master and topic1 first diverged. The old master branch is then lying around in their repositories and will be garbage collected at some point in the future because nothing points to it anymore.

If topic1 is a branch that originated from the current HEAD of master you will be fine here. Otherwise you will get into the “rewriting history” situation which can make a mess of your e.g. your tags. You need to think carefully about what you’re really trying to achieve. Maybe a simple git merge will serve you better?

Bombe
+4  A: 
Pat Notz
good explanation
Sujoy