Useful for signing multiple previous commits in cases that you are the only author for (use the following section for multi-contributor signing)
Use $ git log
to see which commits need to be signed off. Any commits missing a line with Signed-off-by: Example Author <author.email@example.com>
need to be re-signed.
Go into interactive rebase mode using $ git rebase -i HEAD~X
where X is the number of commits up to the most current commit you would like to see.
You will see a list of the commits in a text file. On the line after each commit you need to sign off, add exec git commit --amend --no-edit -s
with the lowercase -s
adding a text signature in the commit body. Example that signs both commits:
pick 12345 commit message
exec git commit --amend --no-edit -s
pick 67890 commit message
exec git commit --amend --no-edit -s
If you need to re-sign a bunch of previous commits at once, find the earliest commit missing the sign off line using $ git log
and use that the HASH of the commit before it in this command:
$ git rebase --exec 'git commit --amend --no-edit -n -s' -i HASH.
This will sign off every commit from most recent to right before the HASH.
You will probably need to do a force push ($ git push -f
) if you had previously pushed unsigned commits to remote.
Instructions for signing off previous commits authored by Daniel Bluhm, sourced from within the Aries-RFCs.
If the DCO signoff is broken across multiple commits that include other developers or commits with co-signers, the following process can help resolve this issue. The following can also address commit authors not matching the 'Signed-off-by: name email' field.
Initiating a git rebase as far back as needing fixing via: git rebase -i COMMIT_HASH_HERE
, and then changing all relevant lines/commits from pick
to edit
.
Once on a commit needing fixing, run:
git commit --amend --no-edit --author="name <email>"
git commit --amend --no-verify
.git commit --amend --author="name <email> --no-verify
git rebase --continue
until the next commit needing fixing or the rebase is complete.Useful StackOverflow answer detailing part of this process.