git-format-patch
使用方法:
git diff ${old-commit} ${new-commit} > commit-operation.patch
OR
git format-patch --stdout - b1af44f > commit-operation.patch (recommend)
THEN
git apply commit-operation.patch
git 帮助信息:
git format-patch -h
usage: git format-patch [<options>] [<since> | <revision-range>] -n, --numbered use [PATCH n/m] even with a single patch
-N, --no-numbered use [PATCH] even with multiple patches
-s, --signoff add Signed-off-by:
--stdout print patches to standard out
--cover-letter generate a cover letter
--numbered-files use simple number sequence for output file names
--suffix <sfx> use <sfx> instead of '.patch'
--start-number <n> start numbering patches at <n> instead of
-v, --reroll-count <n>
mark the series as Nth re-roll
--rfc Use [RFC PATCH] instead of [PATCH]
--subject-prefix <prefix>
Use [<prefix>] instead of [PATCH]
-o, --output-directory <dir>
store resulting files in <dir>
-k, --keep-subject don't strip/add [PATCH]
--no-binary don't output binary diffs
--zero-commit output all-zero hash in From header
--ignore-if-in-upstream
don't include a patch matching a commit upstream
-p, --no-stat show patch format instead of default (patch + stat) Messaging
--add-header <header>
add email header
--to <email> add To: header
--cc <email> add Cc: header
--from[=<ident>] set From address to <ident> (or committer ident if absent)
--in-reply-to <message-id>
make first mail a reply to <message-id>
--attach[=<boundary>]
attach the patch
--inline[=<boundary>]
inline the patch
--thread[=<style>] enable message threading, styles: shallow, deep
--signature <signature>
add a signature
--base <base-commit> add prerequisite tree info to the patch series
--signature-file <file>
add a signature from a file
-q, --quiet don't print the patch filenames
git 变量KV命名:
git -h
Unknown option: -h
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
# For Example
git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree format-patch --stdout - b1af44f > commit-operation.patch
3.两种patch的比较:
- 兼容性:很明显,git diff生成的Patch兼容性强。如果你在修改的代码的官方版本库不是Git管理的版本库,那么你必须使用git diff生成的patch才能让你的代码被项目的维护人接受。
- 除错功能:对于git diff生成的patch,你可以用git apply --check 查看补丁是否能够干净顺利地应用到当前分支中;如果git format-patch 生成的补丁不能打到当前分支,git am会给出提示,并协助你完成打补丁工作,你也可以使用git am -3进行三方合并,详细的做法可以参考git手册或者《Progit》。从这一点上看,两者除错功能都很强。
- 版本库信息:由于git format-patch生成的补丁中含有这个补丁开发者的名字,因此在应用补丁时,这个名字会被记录进版本库,显然,这样做是恰当的。因此,目前使用Git的开源社区往往建议大家使用format-patch生成补丁。
git-format-patch的更多相关文章
- git diff 生成patch, git apply patch 打补丁方法说明,以及分支管理的简单操作。
git diff 简易操作说明 先git log 查看commit ID, 记录你想要打的补丁的ID 比如说: git log commit 4ff35d800fa62123a28b7bda2a04e ...
- Git的Patch功能
转自:http://www.cnblogs.com/y041039/articles/2411600.html UNIX世界的软件开发大多都是协作式的,因此,Patch(补丁)是一个相当重要的东西,因 ...
- git 生成patch 和打入patch
转载:https://blog.csdn.net/liuhaomatou/article/details/54410361 平时我们在使用git 管理项目的时候,会遇到这样一种情况,那就是客户使用gi ...
- 如何使用git 生成patch 和打入patch【转】
本文转载自:http://blog.csdn.net/liuhaomatou/article/details/54410361 平时我们在使用git 管理项目的时候,会遇到这样一种情况,那就是客户使用 ...
- 如何使用git 生成patch 和打入patch 标签: gitpatch【转】
本文转载自:http://blog.csdn.net/liuhaomatou/article/details/54410361 平时我们在使用git 管理项目的时候,会遇到这样一种情况,那就是客户使用 ...
- git diff patch方法
UNIX世界的软件开发大多都是协作式的,因此,Patch(补丁)是一个相当重要的东西,因为几乎所有的大型UNIX项目的普通贡献者,都是通过 Patch来提交代码的.作为最重要的开源项目之一,Linux ...
- [Git] Use git add --patch for better commit history and mitigating bugs
Let's split our changes into separate commits. We'll be able to check over our changes before stagin ...
- git diff patch
如何生成patch:修改一个地方,然后git diff > xxx.patch 就会生成一个patch文件,这里的关键似乎是, 源文件的某个模块的版本要和线上发布的最新版本要一致,这样patch ...
- git 生成patch和打patch
有这样的 目录层次 x/xx/xxx/xxx/ttt.c而 我的 当前位置 是在 x/下 ,执行git diff> test.patch 在test.patch补丁文件里的路径信息是这样的:- ...
- git 生成patch和应用patch【转】
本文转载自:http://www.jianshu.com/p/814fb6606734 1.在git源码目录下执行 1.1.两个commit间的修改(包含两个commit) git format-pa ...
随机推荐
- Chrome 禁止从页面打开 Data URI 网址了
现如今,网民的网络账户被盗,很有可能是被“钓鱼”了.去年的一份安全报告中指出:“近85%的资金损失是通过钓鱼网址泄露支付信息造成的”. 传统的钓鱼网站通常是申请一个和被冒充网站相似的域名,比如 tao ...
- MySQL的一些基本命令笔记(3)
指明外键: 1 :1 两个表中的主键都可以当成外键 1 :N 在 "多" 的实体表中新增加一个字段,该字段是 "一" 实体表的主键 M : N 拆成两个1 :N ...
- Javaweb学习笔记——(二十八)——————Servlet3.0、动态代理、类加载器
web最后一天:完了. Servlet3.0 一.要求 1.MyEclipse10.0或以上版本 2.发布到Tomcat7.0或以上版本 二.步骤 ...
- cmd 命令添加防火墙端口
windows dos 命令添加防火墙端口. 示例 123 端口: netsh firewall add portopening protocol = UDP port = name = NTPSER ...
- vue之生命周期函数例子
执行代码看生命周期函数的执行顺序 <!-- 根组件 --> <!-- vue的模板内,所有内容要被一个根节点包含起来 App.vue --> <template> ...
- Shell 自动安装 JDK
1. 脚本文件 installjdk.sh 注意: EOF 前后不能有空格 #!/bin/bash BASE_SERVER=192.168.1.11 yum install -y wget wget ...
- 华为交换机配置stelnet登陆的实例
作者:邓聪聪 为满足等堡安全要求,对测评对象的交换机做安全登陆的限制 :开启ssh的服务 stelnet server enable :#创建认证用户的用户名和密码 aaa local-user te ...
- C#基础零碎知识点摘录
1.类分为静态类个非静态类(实例类) 静态类不能创建对象,使用方法时,直接类名.方法名(),常用的静态类有Console类 实例类:创建对象时通过对象调用类的方法 2.当我们声明一个类成员为静态时,意 ...
- Lua与C
[前言] 对于Lua的基础总结总算告一段落了,从这篇博文开始,我们才真正的进入Lua的世界,一个无聊而又有趣的世界.来吧. Lua语言是一种嵌入式语言,它本身的威力有限:当Lua遇见了C,那它就展示了 ...
- git提交忽略某些文件或文件夹
记得第一次用 github 提交代码,node_modules 目录死活传不上去,哈哈哈,后来才知道在 .gitignore 文件里设置了忽略 node_modules 目录上传.是的, .gitig ...