如何在 git 补丁中添加 Signed-off-by 字段

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13457203/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:56:26  来源:igfitidea点击:

How to add the Signed-off-by field in the git patch

git

提问by MOHAMED

I'm generating a git patch. And then I want to send it to the project maintainer.

我正在生成一个 git 补丁。然后我想把它发送给项目维护者。

I want to mark my Name and my email address as signed-off-byin the git patch

我想signed-off-by在 git 补丁中标记我的姓名和电子邮件地址

How to do it ? in order that the project maintainer get the signed-off-byfield with my name and email address.

怎么做 ?以便项目维护者获得signed-off-by带有我的姓名和电子邮件地址的字段。

回答by Brian Campbell

When you commit, just use:

提交时,只需使用:

git commit -s

or

或者

git commit --signoff

Or you can just write at the end of the commit message, on a line by itself separated by a blank line from the body of the commit:

或者你可以只写在提交消息的末尾,在一行上,由一个空行与提交正文分开:

Signed-off-by: Your Name <[email protected]>

If you already have the commit, use git commit -s --amendto add the above signoff line.

如果您已经有了提交,请使用git commit -s --amend添加上面的签名行。

Or, if you are going to be sending this as a patch or patch series, you can use git format-patch -sor --signoffto add the signoff to the patch itself, without modifying the commit.

或者,如果您要将其作为补丁或补丁系列发送,您可以使用git format-patch -s--signoff将签收添加到补丁本身,而无需修改提交。

回答by Shanu Dey

use git commit -s --amendfor amending with the last commit or use git commit -sto current ongoing commit. It will add Signed-off-by: YourGitConfigName <YourGitConfigEmail>ad the end of the commit message.

使用git commit -s --amend与最后的修改提交或使用git commit -s当前正在进行的承诺。它将Signed-off-by: YourGitConfigName <YourGitConfigEmail>在提交消息的末尾添加广告。

回答by Ma Si

To set all commits for a repository to be signed by default, in Git versions 2.0.0 and above, run git config commit.gpgsign true. To set all commits in any local repository on your computer to be signed by default, run git config --global commit.gpgsign true.

要将存储库的所有提交设置为默认签名,请在 Git 版本 2.0.0 及更高版本中运行git config commit.gpgsign true. 要将计算机上任何本地存储库中的所有提交设置为默认签名,请运行git config --global commit.gpgsign true.

It is useful using IDE like PhpStorm ;)

使用像 PhpStorm 这样的 IDE 很有用;)