1

I would like to know if there is a method to apply a patch in a more "smart" way. I want to apply an old patch to a file where I have inserted new lines of code. Normally, in this situation "git apply" gives an error message. There is a way to solve this? For instance: I have an original file called test file.txt:

Test File

My favourite colour is : Green

Then , I make a git commit, and modify the file like this:

Test File

My favourite colour is : Orange

Again, I make a new commit, and create a patch file with git format-patch to the previous version. Let's call this file Orange-fix.patch

Now, I roll back to the first commit with git checkout

I modify again the test file file, so it looks like this:

Test Files

1 New line added
2 Other new line added

-- My favourite colour is : Green

If I try to apply the Orange-fix.patch to this file with git apply, I get a "error: testfile.txt: patch does not apply" error message, because new lines have been inserted.

Thanks

DavidGuaita
  • 501
  • 1
  • 7
  • 18

0 Answers0