git help! I’ve got two local branches (X and master) and their remote counterparts in github. What’s the right way to merge X into master?
Here’s the situation in more detail: I had a “feature branch” for the new
luarocks doc command, and I published it on Github to get some feedback. So, at that point I had four branches: in my machine I had master and luarocks-doc. But I also had master and luarocks-doc in github as well. I’ve been pushing master into origin/master and luarocks-doc into origin/luarocks-doc… I thought about doing a straightforward local merge but history could get messy and people would complain I didn’t do it right.
Alexander Gladysh came to the rescue, with the following sequence, which he listed to me through IM and worked flawlessly:
git fetch git checkout master git merge --ff-only origin/master git checkout luarocks-doc git merge --ff-only origin/luarocks-doc git rebase master git checkout master git merge --ff-only luarocks-doc git push origin master
As he said, “then you want to either update or delete luarocks-doc in the origin”:
git push -f origin luarocks-doc
git push origin :luarocks-doc
The –ff-only flag tells merge not to perform incomplete merges (as it happened to me so often!) so it only runs it if the command would perform its task completely.
Alexander also gave me some links to material on Git workflow models, which I’ll be sure to read:
Hope that helps you as Alexander helped me. Sharing it forward!
Fill out the form below to add your own comments.