I have two branches dev
and master
. I want my dev branch to be completely overwritten by master
branch as I know master is latest. How can I do that using TortoiseGit UI?
I tried to do merge using TortoiseGit but that would result in many conflicts.
Please let me know the answers in Tortoise GIT only as I am only using UI and not familiar with actual GIT commands.
Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches. It is always used with source and destination branches mentioned as parameters.
Choose Team → then Advanced → then Rename branch. Then expand the remote tracking folder. Choose the branch with the wrong name, then click the rename button, rename it to whatever the new name. Choose the new master, then rename it to master.
Disclaimer : this is not a TortoiseGit solution, but a CLI one, I hope it'll help someone anyway.
Since nobody suggested it already, let's also note this quite simple way to do it :
git branch -f dev master
It's a short way to set the first given ref (here : dev) to the same point where the second ref (here : master) is currently pointing to. (As a sidenote, they're not "linked" in any way after this command, and stay independant for all intents and purposes.)
As it rewrites the history of branch dev, if it has a remote counterpart you'll have to push it with force :
git checkout dev
git push -f origin HEAD
In any case, if you happen to have other people working with you on that branch, any of the solutions here are ways to rewrite history so be sure to discuss this with them beforehand!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With