Reputation: 23497
Say I have a diff file looking basically like the following.
+line a
-line b
Is it possible to do one (or both) of the following:
Inverse this file (so I'd get)
-line a
+line b
Pass some argument to patch
so the end result the same as applying
the inversed diff file described above
Upvotes: 15
Views: 7185
Reputation: 1828
You can leave the diff as is and apply in reverse
git apply --reverse backwards-diff
Upvotes: 12
Reputation: 46813
To rewrite a reversed / inverted diff file, use interdiff
from diffutils:
interdiff -q my-diff-file /dev/null
Upvotes: 11
Reputation: 2903
Here is what you should do (assuming newFile.txt is the file you want to apply the reversed diff file on and diffFile.txt is the diff file):
patch -R newFile.txt diffFile.txt -o oldFile.txt
Upvotes: 6