generate patches by git

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


if you'd like to get patches since one special commit but not the latest, for example r1, then try

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值