Git add line with output using format.signoff not working

My client version of git is 1.7.0.4.

I want to automatically add the “Connected” line for the committer at the end of the commit log message while committing the message.

  • When I set git config --global format.signoff true and run git commit -m "modify something" , I don't see "Signed-off-by" in git log .
  • If I use git commit -m -s "modify something" then "Connected" is displayed in git log .

Can anyone help?

+14
source share
3 answers

Update for Git 2.14.x / 2.15: as I mentioned in Git Detection, if the commit is completed programmatically , you can parse the commit message trail for the Signed-off-By string.

" git interpret-trailers " has been explored by --parse and several other options to make it easier for scripts to grab existing trailer lines from a commit log message.

See the stefanct answer for commit-msg on the client side , which will use git interpret-trailers .


Original answer (2013)

format.signoff about the patch (as shown, for example, in this patch ):

 format.signoff 

Boolean value that enables the -s / - signoff format-patch option to be enabled by default

It is not related to git commit -s .

In other words, you don't have to sign each commit, but when you publish them as a patch for others to use (as in git: posting patches "), then you have to sign them.

For the exact Signed-of-by value, see What is the Git Shutdown Function for? "

+6
source

You can sign by default in the project by creating a file (say "~ / MYPROJECT / git-template") that contains several blank lines and signed text, for example:

 Signed-off-by: Your Name < your.email@example.com > 

Then configure git to use it as a commit template. For example:

 git config commit.template ~/MYPROJECT/git-template 

Make sure your project is documented somewhere, which means a signature for the project. Here is the text that you can copy to your CONTRIBUTING.md file:

All contributions (including retrieval requests) must comply with version 1.1 of the Developer Origin Certificate (DCO). This is exactly the same that was created and used by the Linux kernel developers and is available at http://developercertificate.org/ . This is a developer certificate that he or she has the right to submit a patch for inclusion in the project. Simple submission of materials implies this agreement, however, please include the “Signed” tag in each patch (this tag is the usual way of confirming your agreement with DCO).

+13
source

Now there is a simple way to automatically exit any commit that has not yet been completed using traps and the git-interpret-trailers command. In the next version 2.15, the git command allows you to trivially check for a signature (regardless of its value / author) and add your own, if it is not already there. As of October 2017, the required code is not yet available in any git release (but in its master branch)!

Save the following as .git/hooks/prepare-commit-msg or .git/hooks/commit-msg (see the differences here ) and make it executable.

 #!/bin/sh NAME=$(git config user.name) EMAIL=$(git config user.email) if [ -z "$NAME" ]; then echo "empty git config user.name" exit 1 fi if [ -z "$EMAIL" ]; then echo "empty git config user.email" exit 1 fi git interpret-trailers --if-exists doNothing --trailer \ "Signed-off-by: $NAME <$EMAIL>" \ --in-place "$1" 
+8
source

All Articles