当前位置:   article > 正文

git patch和使用_git patch作用

git patch作用

patch作用:修复了基线的一个bug,在未合并代码的时候,同步到各个版本的发布分支,用于解决问题

1、patch生成方式

# 方法一
# git 上传代码到页面后,git数字编号后去掉+.patch刷新页面,复制更改部分,切换到git工作目录粘贴文件为file_name
# 打补丁
git am file_name

# 方法二
# 生成补丁
git diff > commit.patch
# 检查补丁
git apply --check commit.patch
# 应用补丁
git apply commit.patch
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

不同的patch生成方式

方式一 本地修改未commit
希望把修改的内容生成patch,可以如下操作:
git diff > commit.patch

对于已经add但是未commit的修改:
git diff --cached > commit.patch

方式二 本地修改已commit
希望把最近一次的修改生成patch:
# 注意:commitId为倒数第二个提交ID
git diff commitId > commit.patch
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

3、应用

# 检查patch是否可以应用
git apply --check commit.patch
# 打单个补丁
git apply commit.patch
# 打多个补丁
git apply ../patch/*.patch
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/641151
推荐阅读
相关标签
  

闽ICP备14008679号