I think my question is close to this one, but I'm using git.
So, let's say I have
Commit1 changed file1.c and file2.c
Commit2 changed file2.c, file3.c, file4.c
Commit3 changed file1.c , file2.c and file3.c
and so on...
Then, I would like to revert only the changes that Commit2 made in file2.c, but, try to keep the changes that Commit3 made in this file...
What you think? There is some way to do it?
Thank you.
You may try to revert Commit2 (that is, apply a new git commit, whose changes would be opposite to the changes made in Commit2) but without committing. There's a instant menu entry in gitk
for example. In this new commit you leave only changes made to file2
and commit the result.
Alternatively, you could simply do something like
git diff Commit2..Commit1 -- file2.c > revert.patch
git apply revert.patch
it might be useful to take a look on the patch before applying it because commits after Commit2 may introduce some conflicts with the changes to file2.c
from Commit2.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments