My client git version is 1.7.0.4.
I want to automatically add a "Signed-off-by" line for the committer at the end of the commit log message when commit a message.
git config --global format.signoff true
, and run git commit -m "modify something"
, I see no "Signed-off-by" in git log
.git commit -m -s "modify something"
, then "Signed-off-by" does show in git log
.Can anyone help?
Sign-off is a line at the end of the commit message which certifies who is the author of the commit. Its main purpose is to improve tracking of who did what, especially with patches.
git config --global alias. add-commit "! git add -A && git commit" (i.e. double quotes instead of single quotes) is what works on Windows.
Without adding any files, the command git commit won't work. Git only looks to the staging area to find out what to commit. Staging, or adding, files, is possible through the command line, and also possible with most Git interfaces like GitHub Desktop by selecting the lines or files that you'd like to stage.
There is now an easy way to automatically sign-off any commit that is not already signed-off by using hooks and the git-interpret-trailers
command. In the upcoming version 2.15 of git the command allows to trivially check for an existing sign-off (no matter what's its value/author is) and add yours if there is non yet. As of October 2017 the required code is not in any git release yet (but in its master
branch)!
Save the following as .git/hooks/prepare-commit-msg
or .git/hooks/commit-msg
(see here for the differences) 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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With