# Signing Off Previous Commits Useful for signing multiple previous commits in cases that you are the only author for ([use the following section](#fixing-broken-signoffs-multi-contributor-commit-author-signoff-mismatch) for multi-contributor signing) 1. 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. 2. 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. 3. 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 ``` 4. 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. 5. 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](https://github.com/hyperledger/aries-rfcs/blob/main/contributing.md#how-to-sign-off-previous-commits).* ## Fixing Broken Signoffs (Multi-Contributor), Commit Author Signoff Mismatch 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. 1. 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`. 2. 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` 3. After the commit, run: `git rebase --continue` until the next commit needing fixing or the rebase is complete. *[Useful StackOverflow answer](https://stackoverflow.com/a/3042512) detailing part of this process.*