🔗 Merging a Git feature branch that was already published on Github
Today I had a Git dillema, which I posted about on Twitter:
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”:
To update:
git push -f origin luarocks-doc
To delete:
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!
Follow
🐘 Mastodon ▪ RSS (English), RSS (português), RSS (todos / all)
Last 10 entries
- There are two very different things called "package managers"
- Last day at Kong
- A Special Hand
- How to change the nmtui background color
- Receita de Best Pancakes
- That time I almost added Tetris to htop
- Receita de Orange Chicken
- Receita de frango empanado no panko
- Receita de cebola caramelizada
- Receita rápida de crepe