Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

recreating file from diff

Tags:

unix

diff

How to create the original file from the diff, I am having one of the files and deleted the other unknowingly. Is there any tool to convert the diff output to 'ed' diff (diff -e output) format or patch output format?

like image 840
user1730177 Avatar asked Feb 25 '26 21:02

user1730177


1 Answers

If you have:

  • the old file, and
  • the diff

then this is simply a matter of applying the diff in the usual fashion:

patch the_file <the_diff

This is just the normal use case for applying a diff.

If you have:

  • the new file, and
  • the diff

then you can you can simply apply the patch in reverse using patch's -R option:

patch -R the_file <the_diff
like image 180
Celada Avatar answered Mar 01 '26 09:03

Celada