Moving master head to a branch

kostja picture kostja · May 25, 2012 · Viewed 20.6k times · Source

I have several feature branches and a master branch. Feature2 is done. Normally I would rebase (working with a remote SVN repo and would like to keep the history, so no regular merge) and ff-merge. But since master hasnt changed since I branched, I would like to move the master head (at E) to G. Using git branch -f master G does not result in any visible changes, I assumed this is because G is on a different branch.

Is it safe to use git update-ref -f master G here instead? Should I stick with rebase/ff-merge? Something even better?

feature1      C-D  
             /
master    A-B-E            
               \                      
feature2        F-G  

Thank you.

Answer

ralphtheninja picture ralphtheninja · May 25, 2012

You don't have to merge the branches, a reset is enough. Assuming master is checked out:

git reset --hard feature2