How to “undo” a previously undone commit?

Imagine the following scenario:

Code that should not have been merged with the integration branch should be returned. However, you cannot just reset, since other commits have occurred since that moment. Alternatively, you can reapply this commit later.

Easy to use git revertfor back fixation. However, what happens when we want to commit this change (for example, from a feature branch)? Are you just re-merging the branch? Will this work, since technically the code has already been merged?

What do you do when you are finally ready to accept this merger?

+4
source share
2 answers

.

git revert HASH_OF_REVERT_COMMIT
+6

, , .


, ,

git <your_branch> merged to master, pushed to origin/master.

, .

/ .

, .

:

git revert -m 1 <commit-ID>
Finished one revert.
[master xxxxxxx] Revert "Merge branch 'xx/your_branch'"
 10 files changed, 0 insertions(+), 12 deletions(-)

git revert . / /.

, , ?

:

git revert <commit-ID>
Finished one revert.
[master xxxxxxx] Revert "Merge branch 'xx/your_branch'"
 10 files changed, 12 insertions(+), 0 deletions(-)

, , .

0

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


All Articles