设为首页 收藏本站
查看: 1135|回复: 0

[经验分享] 步骤:用git提交patch,并发送邮件列表

[复制链接]

尚未签到

发表于 2018-9-18 07:05:01 | 显示全部楼层 |阅读模式
  一. 先配置git send-mail 的 smtp服务器:
  1. 安装git-email:
  # apt-get install git git-core git-email
  修改gitconfig文件:vim ~/.gitconfig
[color]  
ui = auto
  
[commit]
  
template = ~/.commit_template
  
[user]
  
name = ***
  
email = ***@***.com
  
[alias]
  
pretty = log --branches --remotes --tags --graph --oneline
  
--decorate
  
[sendemail]
  
smtpencryption = tls
  
smtpserver = smtp.gmail.com
  
smtpuser = *****.****@gmail.com
  
smtpserverport = 587
  
smtppass = abcdef
  

  
suppresscc = all //will suppress all auto cc values
  
confirm = always
  
#to = *****.****@gmail.com //Specify the primary recipient
  
#cc = s***linux@freelists.org //CC list
  2. Then edit
the .git/hooks/pre-commit file
to contain only the following two lines:
#!/bin/sh  
exec git diff --cached | scripts/checkpatch.pl --no-signoff - || true
  二. 好了,下面就是提交的步骤了。
  1. 按功能分类提交commit ,提交之前先执行脚本 ./scripts/cleanfile xx.

  •   加-s选项,自动Signed-off-by.
  •   git commit
    --amend --author " Xxx Zhang "(添加实际的author,如果author是本人,则不要写)
  •   commit message
    第一行要是patch的主题(包括patch的从属子系统,和概述),第二行是patch的详细描述。
  •   如果想修改其中的一个commit:
      a)git
    format-patch -n
      b)git
    reset到那个commit,如要更改或添加某个文件,git add; 如要删除某个commit的文件,(git reset
    HEAD^ file),然后 commit --amend
      c)git am *.patch (不用git
    apply,因为apply命令只将patch应用到index,而不会将commit
    message同时应用到git仓库上。如果当前目录下之前执行过git-am,而没有发送email,需要先执行git am
    --abort放弃掉之前的am信息。遇到了一次abort不掉的时候,执行rm -rf
    .git/rebase-apply/就可以了,参照如下Linkhttp://git.661346.n2.nabble.com/Dangerous-quot-git-am-abort-quot-behavior-td5853324.html)
  2. 生成patch:

  •   git format-patch -2 --cover-letter//2表示从HEAD的commit开始,向前生成两个commit的patch。--cover-letter会生成一个0000-cover-letter.patch,格式和commit
    message类似,第一行是patchset的主题,第二行描述这组patchset的详细信息,它就是邮件中的【PATCH
    0/n】(有必要的话,将测试结果和基于的主线版本写在0000-cover-letter.patch中的详细描述中)。
  •   git format-patch -numbered --cover-letter
    --subject-prefix="PATCH v2" (如果不是第一版   patch需要添加版本号,以v2为例)
  3. 检查patch:
  ./scripts/checkpatch.pl
0001-nfs-add-a-pr_info.patch (不用检查0000-cover-letter.patch)
  4. 发邮件列表:
  git send-email *.patch
  如果想要编辑patch邮件内容,加--annotate选项。
  编辑完一个退出vim用:wn命令,编辑下一个patch,直到最后一个直接wq退出vim即可。
  $ git send-email
*.patch
  /tmp/59yD80Mjvb/0000-cover-letter.patch
  /tmp/59yD80Mjvb/0001-clone-patch-test-001.patch
  /tmp/59yD80Mjvb/0002-revised-text.patch
  3 files to edit
  Who should the emails appear to be from? [chunyan.zhang ]zh**.****@gmail.com//输入发件人邮箱
  Emails will be sent from: zhang.lyra@gmail.com
  Who should the emails be sent to? z***@gmail.com //输入收件人邮箱
  Message-ID to be used as In-Reply-To for the first email?for_test//随便输入一个ID
  附:标准的patch格式
  The canonical patch subject line is:
  Subject: [PATCH 001/123] subsystem: summary phrase
  The canonical patch message body contains the following:
  - A "from" line specifying the patch author.
  - An empty line.
  - The body of the explanation, which will be copied to the
  permanent changelog to describe this patch.
  - The "Signed-off-by:" lines, described above, which will
  also go in the changelog.
  - A marker line containing simply "---".
  - Any additional comments not suitable for the changelog.
  - The actual patch (diff output).
  参考:
  http://www.freedesktop.org/wiki/Software/PulseAudio/HowToUseGitSendEmail/
  http://blog.chinaunix.net/uid-28453894-id-3552774.html
  http://kernelnewbies.org/OPWfirstpatch



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-588880-1-1.html 上篇帖子: Git+Gerrit学习搭建笔记 下篇帖子: git命令使用总结
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表