DEV Community

JJ Asghar
JJ Asghar

Posted on

Signing Commits in `git`

I found myself googling how to set it up a couple of times. Here are my notes on how to set up git so you are now in compliance.

I should make it clear that the difference between signoff and gpg-sign are significant but subtle. signoff doesn't require the GPG key and is just the line: "Signed-off by" which is covered in the following quote.

DCO process only requires:

Moving forward all commits to open source software projects must include a "Signed-off-by" line indicating the name and email address of the contributor signing off on the change.

For a detailed description or you can just do the following:

$ git commit -s
$ # Or
$ git commit --signoff
Enter fullscreen mode Exit fullscreen mode

If you already have the commit, use git commit --amend or git rebase -i to edit your commit message, and add the above signoff line.


If you would like something more permanent, you can add to your ~/.gitconfig something like the following:

  amend = commit -s --amend
  cm = commit -s -m
  commit = commit -s
Enter fullscreen mode Exit fullscreen mode

Or you can do something like Dave Parfitt suggests; which is surprisingly easy. You can add this to your ~/.gitconfig: (be sure to change your name and email address)

    template = ~/.gitmessage
Enter fullscreen mode Exit fullscreen mode

followed by:

~$ cat ~/.gitmessage

Signed-off-by: Your Name <>
Enter fullscreen mode Exit fullscreen mode


If you are attempting to do it in emacs with magit you need to
the following:

c - s RET and you'll notice the (--signoff) switch become highlighted.

Top comments (0)