通过git diff 命令生成patch文件

通过git diff 命令生成patch文件

1.还未提交的修改

命令 :git diff > commit.patch

2.已提交的修改

复制代码
先用git log命令查看commit id
soft04@lzy-pc:~/work/code/p716qc-e3x-qz-noback$ git log
commit 8b5100cdcd3895c1b9f44ef042b120fd2b4dfc7b
Author: xxxx <xxxx@163.com>
Date:   Tue Nov 19 18:45:05 2019 +0800

    test

commit 3da71ca35b7d62894330dbdf8cee1d653a3e26df
Author: xxxx <xxxx @163.com>
Date:   Thu Nov 14 16:21:18 2019 +0800

    去掉toast
   
通过命令生成patch
命令 :git diff 3da71ca35 8b5100cdcd > commit.patch
复制代码

3.已经add但是未commit的修改

命令 :git diff --cached > commit.patch

4.检查patch是否可以应用

命令 :git apply --check commit.patch

 

5.查看patch文件

命令 :cat commit.patch

 

6.打补丁

命令 :git apply commit.patch

 

生成的commit.patch文件

 

posted @ 2023-02-14 11:27  我家有只江小白  阅读(474)  评论(0编辑  收藏  举报