Revert merge git-flow

I am using SourceTree and Git-Flow pattern. Now I have prepared the release for my beta testers for testing, so I created a new branch release/v1.0.1 . But my mind slipped, and I decided to finish (merge both develop and master and the tag) release, although I did not even send the release to my testers. Therefore, I would like the release branch to open again, if my testers find any errors, I can fix these errors in the release branches, and then, when all the errors are fixed, I can finish the release.

So, how can I easily use SourceTree (or with git commands) to return to the state when I had the release/v1.0.1 ?

Attached screendump from SourceTree:

enter image description here

EDIT: Well, I did git reset --hard HEAD~2 to develop (HEAD ~ 2), because I manually checked the check. But now, when I check master and do a git reflog , it seems to me that I should do a reset to HEAD ~ 6

 Peters-MacBook-Pro:Remessage peterwarbo$ git reflog f7663b1 HEAD@ {0}: checkout: moving from develop to master 3d132da HEAD@ {1}: reset: moving to HEAD~2 2f1c753 HEAD@ {2}: checkout: moving from master to develop f7663b1 HEAD@ {3}: checkout: moving from develop to master 2f1c753 HEAD@ {4}: merge release/v1.0.1: Merge made by the 'recursive' strategy. 4332fe4 HEAD@ {5}: checkout: moving from master to develop f7663b1 HEAD@ {6}: merge release/v1.0.1: Merge made by the 'recursive' strategy. fe323ef HEAD@ {7}: checkout: moving from release/v1.0.1 to master 28a63ea HEAD@ {8}: commit: Bumped version number to 1.0.1 

But when I do this, I get this β€œerror”:

 Peters-MacBook-Pro:Project peterwarbo$ git reset --hard HEAD~6 fatal: ambiguous argument 'HEAD~6': unknown revision or path not in the working tree. 

EDIT 2: A new image to illustrate a fuckup.

enter image description here

EDIT 3: A new image is attached to illustrate the current state after issuing git commands in user1615903 response. Why does he say development costs 2? And why is there a merge from release/v1.0.1 to handle, even if I reset to master the initial commit ( fe323ef )?

enter image description here

+4
source share
1 answer

This is pretty easy. You will need to do the following:

  • Reset to develop a branch for fixation that was before merging

  • Reset the main branch for the commit that was before the merge

  • Make release release point the correct commit

  • Remove tag

  • Push fixed commit to remote

So, to do steps 1 and 2:

 git checkout develop git reset --hard 4332fe4 git checkout master git reset --hard <SHA of the commit the master was before the merge> 

Then, to "recreate" the release branch:

 git checkout -b "release/v1.0.1" 28a63ea 

And finally, remove the tag:

 git tag -d v1.0.1 

Learn more about canceling a merge at fooobar.com/questions/258 / ...

After that, if the changes have already been pushed, you need to use the -f switch to override the changes remotely:

 git push -f 

And remove the tag from the remote:

 git push --delete origin v1.0.1 
+8
source

Source: https://habr.com/ru/post/943607/


All Articles