purely some records about the way to generate git patches. and the cmd got from the web mostly.
1. most frequently used:
#generate the lastest one patch commited
git format-patch HEAD^
#generate the lastest two patch commited
git format-patch HEAD^^
more patches you want, more "^" appends to the end of the "HEAD", just simple and nice.
but the problem comes now, what if you just want the all patches from the latest to the orignal codebase? how do i know how much "^" should i added.
take it easy, suppose your current branch is "dev1", just try this:
git format-patch –root dev1
as mostly your branches comes from the original "master" branch, if you'd like to get all patches since the original master branch till your current working branch, try
git format-patch master
git format-patch <r1>
remember that the "r1" commit will not be included.
if just one commit but not all since this commit is prefered, then simply add "-1"
git format-patch -1 <r1>
what if 2 patches, 3, 4, or 11?
just change the number of "1" to whatever as you wish :-)
the common usage is
git format-patch –n <rsha>
the "n" is just the count of patches you want.
how about i just want patches between two commits but do not know or just donot want to care how many patches bewteen then?
here it is
git format-patch <r1>..<r2>
the difference is here the two commits "r1" and "r2" will be included.
as i just collect infos about patch generation here, some other git related cmd for patch handle is not contained.
the reference URL provide more interesting details you may be interested.
like compare one file from two branches:
git diff dev1 dev2 main.c
REF:
http://blog.csdn.net/wh_19910525/article/details/19416857
http://blog.chinaunix.net/uid-28621021-id-3487102.html
http://blog.csdn.net/kevinx_xu/article/details/11660915