git format-patch 常用方法

来源:互联网 发布:大数据经济新常态 编辑:程序博客网 时间:2024/04/28 17:29

1.仓库中,master上开出一个新的branch,暂定为alex。

2.git checkout alex

   vim file

   git add file

   git commit -m "1st modify --- alex branch"

3.git show-branch --more=4 alex

  [alex] 1st branch modify alex
  [alex^] creat test file.

4. 创建patch。

    git format-patch -1

    或者 :

     git format-patch alex^..alex

 5. git checkout master

     git apply *.patch

     git apply *new.patch

至此,patch成功地打入到master上。



Note:

1.请注意,git apply 是一个事务性操作的命令,也就是说,要么所有补丁都打上去,要么全部放弃。

2.对于传统的 diff 命令生成的补丁,则只能用 git apply 处理。

   对于 format-patch 制作的新式补丁,应当使用 git am 命令。