15

With git 1.7.9, it's possible to sign a commit with the -S option. Is it possible to set it default through git config --global?

So instead of git commit -S -m 'Commit message', it would be just git commit -m 'Commit message'.

tamasd
  • 253

1 Answers1

12

To sign automatically all future git commits, you can define a global alias. For example, to create a global alias called "c", you would do this:

$ git config --global alias.c 'commit -s'

(note that the commit switch to sign off is lowercase "-s" and NOT uppercase "-S", as you typed in your question).

After having done this, you can start doing your commits using your newly created "c" alias. Here's an example of creating and commiting a file called "test.txt" that will be signed off by the committer:

$ vim test.txt
[edit file]
$ git add test.txt
$ git c -m 'My commit message'

You can see that the commit has the "Signed-off-by:" line if you run the "git log" command with the --pretty=fuller option:

$ git log --pretty=fuller
ricmarques
  • 1,146