All projects under the Linux Foundation enforce Developer Certificate of Origin (DCO) on all commits/Pull Requests, which is frequently validated by a DCO Bot.
This means that all commits must be signed-off, which can be done in git with -s:
git commit -s -m "commit message here"
Pretty easy!
Signing off your previous commits
However, if you didn’t know about this requirement or just forgot before you made a commit, you’ll need to signoff those previous unsigned commit(s), which is slightly less straightforward:
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 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.
Fixing Multi-Contributor Unsigned Commits or Commit Author Signoff Mismatches
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.
Initiate 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>"
Additionally, if there are co-signers or multiple signers, the commit author must be the last DCO sign-off in the commit message (including after any co-signers). In order to adjust this you can run git commit --amend --no-verify.
These can be combined as:
git commit --amend --author="name <email> --no-verify
After the commit, run: git rebase --continue until the next commit needing fixing or the rebase is complete.
You should now be all set! Good luck with the PR!
Helpful sources:
- Useful StackOverflow answer detailing part of this process.
- Aries RFC repo