M
M
Michael2018-08-06 21:15:42
git
Michael, 2018-08-06 21:15:42

How to apply reverse changes in git?

There is a dev branch and test-branch (the same). There was a test piece of code in the dev branch that was removed. In test-branch, I want to return that removed piece of code so that when merge dev on test-branch, the code is not lost. Like a cherry-pick with the reverse changes.
How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2018-08-06
@springimport

Solution: you need to go to test-branch and select a commit to apply the code:
git checkout HEAD~ -- .(instead of HEAD~, you can have a commit hash).
PS The snag in -- . - this allows you not to move HEAD.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question