How to rewrite a specific branch using the wizard

I have two branches dev and master . I want my dev branch to be completely overwritten by the master branch, since I know that the master is the last. How can I do this using the TortoiseGit UI?

I tried to merge using TortoiseGit, but this will lead to conflicts.

Please let me know the answers in Tortoise GIT just because I only use the user interface and am not familiar with the actual GIT commands.

+8
git tortoisegit
source share
3 answers

In TortoiseGit, you have several options depending on your scenario:

  • You are in the dev branch: go to the log dialog box, open the context menu in the main entry of the branch and select "Reset to" and select "hard".

  • You are not in the dev branch: create a new branch called dev select the master branch as the origin and select "Override the branch if it exists" (or go to the log dialog, open the context menu in the dev branch and select delete branch and open the context menu in the master branch and create a new branch called dev ).

0
source share

Disclaimer: This is not a TortoiseGit solution, but a CLI solution, I hope it helps someone anyway.

Since no one suggested this, let me also point out that this is a fairly simple way to do this:

 git branch -f dev master 

This is a short way to set the first given ref (here: dev) to the same point that the second ref (here: master) is currently pointing to. (As a note, they are in no way โ€œconnectedโ€ after this command and remain independent for all intents and purposes.)

Since it rewrites the history of the dev branch, if it has a remote counterpart, you will have to push it with force:

 git checkout dev git push -f origin HEAD 

In any case, if you have other people working with you in this thread, any of the solutions here are ways to rewrite the story, so be sure to discuss this with them in advance!

0
source share

I have no idea if this is right or wrong, but I seem to rewrote another branch with a master like this:

 git push origin master:otherbranch 

And then, when I switched, I had to pull, and was it good to go?

-one
source share

All Articles