Git 对开源项目修改并生成patch文件
1.fork源码
2.git clone 自己的源码
3. git branch 查看当前分支和使用过的历史分支
4. git branch -r 查看该项目的所有分支
5. git checkout KYLIN-2654
6. 修改代码
7. 添加修改过的文件,提交修改
8. 查看提交
9. 撤销commit
10. 生成patch文件git format-patch <hash_new> <hash_old>
1. fork源码
2. git clone 自己的源码
3. git branch 查看当前分支和使用过的历史分支
$ git branch
KYLIN-2535
* KYLIN-2653
master
4. git branch -r 查看该项目的所有分支
$ git branch -r
origin/2622-2764
origin/HEAD -> origin/master
origin/KYLIN-1351
origin/KYLIN-2165
origin/KYLIN-2242
origin/KYLIN-2246
origin/KYLIN-2314
origin/KYLIN-2351
origin/KYLIN-2360
origin/KYLIN-2374
origin/KYLIN-2477
origin/KYLIN-2501
5. git checkout KYLIN-2654
6. 修改代码
vim core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
7. 添加修改过的文件,提交修改
git add core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
git commit -m "Fix the bug KylinConfig cannot read properties from the config file kylin.properties"
git add server-base/src/main/java/org/apache/kylin/rest/security/AuthoritiesPopulator.java
git commit -m "Add control of authorities for ladap users via config the file kylinSecurity.xml without monify ldap system"
8. 查看提交
$ git log
commit 14aced0724caff6cef483b547120e5c363e7609f (HEAD -> KYLIN-2653)
Author: makexu <makexu_hust@163.com>
Date: Tue Dec 5 15:17:05 2017 +0800
Fix the bug KylinConfig cannot read properties from the config file kylin.properties
commit 276fa2c4dafd22cd897227d5cc592cd528f40cc5 (origin/KYLIN-2653)
Author: kangkaisen <kangkaisen@meituan.com>
Date: Fri Jul 14 21:31:49 2017 +0800
Tmp annotated CalciteParser.ensureNoTableNameExists
commit 3326b0897b3f839cc34c9c8030571d02627d2629
Author: kangkaisen <kangkaisen@meituan.com>
Date: Thu Jul 13 20:18:17 2017 +0800
KryoRegistrator add ComputedColumnDesc
9. 撤销commit
git reset --soft HEAD~1
在保证你修改的基础上撤销一次commit
如果使用--hard 会把你的修改也删除掉
10. 生成patch文件git format-patch <hash_new> <hash_old>
$ git log
commit 30d5d5326b162d51571955e842ec3299aedd615d (HEAD -> KYLIN-2653)
Author: makexu <makexu_hust@163.com>
Date: Tue Dec 5 15:49:22 2017 +0800
Add control of authorities for ladap users via config the file kylinSecurity.xml without monify ldap system
commit 5e68d70c00f8a8c8c5581458be7d00f1679e7421
Author: makexu <makexu_hust@163.com>
Date: Tue Dec 5 15:37:28 2017 +0800
Fix the bug KylinConfig cannot read properties from the config file kylin.properties
commit 276fa2c4dafd22cd897227d5cc592cd528f40cc5 (origin/KYLIN-2653)
Author: kangkaisen <kangkaisen@meituan.com>
Date: Fri Jul 14 21:31:49 2017 +0800
Tmp annotated CalciteParser.ensureNoTableNameExists
commit 3326b0897b3f839cc34c9c8030571d02627d2629
Author: kangkaisen <kangkaisen@meituan.com>
Date: Thu Jul 13 20:18:17 2017 +0800
KryoRegistrator add ComputedColumnDesc
commit 6413c286ea1d18ea1a8bb2bf9e975e162a08b39f
$ git format-patch 30d5d5326b162d51571955e842ec3299aedd615d...276fa2c4dafd22cd897227d5cc592cd528f40cc5
0001-Fix-the-bug-KylinConfig-cannot-read-properties-from-.patch
0002-Add-control-of-authorities-for-ladap-users-via-confi.patch
http://www.cnblogs.com/makexu/

浙公网安备 33010602011771号