Solved how to create patches using diff without copy of original file

Solved issue

jindam

New Member
Joined
Nov 13, 2023
Messages
6
Reaction score
0
Credits
61
* right now i am creating .patches using
Code:
diff -u OriginalFile UpdatedFile > PatchFile
* however, if i list original file,
patches will be useless
* how do i create patches without
need to keep of original file?
  • example_
  • i will make 10 edits to a file
along with patches, edit1.patch,
edit2.patch .... edit10.patch and
i have latest edited file: file.txt
* i want to view what i have added
in 7th patch, is it possible to
apply edit7.patch on file.txt with
discarding changes from edit8.patch?
 


Moving this to Command Line.

Good luck

Wizard
 
No you can't. You need the original. You can't patch what you don't have.

diff -u original_file.c updated_file.c > mypatch.patch

This will create a unified diff format patch file named mypatch.patch.

patch original_file.c < mypatch.patch
This will apply the patch.

It's best to have the patch and the original file in the same directory. If they aren't you can do this...

patch -p1 < mypatch.patch

The -p1 strips the leading paths.
 
Last edited:


Latest posts

Top