BeginnersSake BeginnersSake - 1 year ago 89
Git Question

Creating patch files in git

I wanted to know whether it is possible to create patch files in git. I mean if I have done some changes in few files then patch file should be created with respect to the filename.

git diff
displays the changes on the console but Is it possible to separate
the output into different files?

Answer Source

git format-patch

Say you've made a commit aaa111 which modifies foo.txt, bar.txt and hello.txt.

git format-patch -1 aaa111

It generates a patch including three files' changes.

git format-patch -1 aaa111 -- foo.txt

It generates a patch including only the change of foo.txt.

git format-patch -1 aaa111 --stdout -- bar.txt > aaa111.bar.patch

It generates a patch named as aaa111.bar.patch which includes only the change of bar.txt

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download