Tuesday, October 14, 2014

Git tips, how to generate patch and apply it

we have one version , for demo. just called file.txt with version1 as the content.

image

after we change it to version 2 , we can run git diff  and redirect output to a patchfile.

by default, diff put  a/b as the prefix.

image

then we reset the workspace and try to apply the patch

image

for some version, you might put patch –p1 to apply the patch , basically means ignore the a/b prefix.

for the generation, we can put –-no-prefix to remove the prefix

image

 

for binary file, we can put –-binary option to generate the patch.

and use git apply –binary to apply the patach.

to tell the diff difference summary you can put the –-stat option.
image

there might be several commits after the last update, you can use format patch to generate one by one if you like

image

 

to apply stacks patch

image

No comments:

 
Locations of visitors to this page