tags:

views:

42

answers:

2

When rewriting a Git repository's history, how do you remove sign-offs (as created by git commit -s or git commit --signoff)?

git filter-branch's commit-filter seems to only support the variables used by git commit-tree:

GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL
GIT_AUTHOR_DATE
GIT_COMMITTER_NAME
GIT_COMMITTER_EMAIL
GIT_COMMITTER_DATE
EMAIL
+2  A: 

Sign offs are just part of the message body. So, you'll want to use git filter-branch --msg-filter to run a command to find lines starting with Signed-off-by: and remove them.

Something like

git filter-branch --msg-filter "sed /^Signed-off-by:/d"

should do the trick.

Brian Campbell
Thanks! This is probably the best way to remove all sign-offs or all sign-offs by a particular person or e-mail address. However, your particular example doesn't remove the newlines before and after the line containing "Signed-off-by:". I'm not too familiar with sed and since it's notorious for not being very well documented, I'll just note this here for completeness.
Mantrum
@Mantrum Yes, this just deletes the sign-off lines themselves. You'll have to do something a little more complicated if you want to delete the extra blank line before the sign-off; you will want to check if there are any other trailing lines below the message (I usually have `Bug:` lines to indicate which bug it fixes, and sometimes `Paired-with:` or `Reviewed-by` to indicate pair programming and code review). Generally on StackOverflow, answers will point you in the right direction, but you may need to fill in some details depending on your exact needs.
Brian Campbell
+1  A: 

For deleting all sign-offs or all sign-offs by a particular person / e-mail address, see Brian's answer.

Based on the information Brian provided (i.e. that sign-offs are part of the commit message), it was easy to figure out how to delete or change individual sign-offs:

Run an interactive rebase (git rebase -i) on the parent of the commit that has the sign-off, find the commit in the editor that pops up and replace pick with reword. In the editor that shows up next, adjust the commit's message to your liking.

Mantrum
Ah, yes. If you just want to delete sign-offs for a particular revision, or a few revisions, `git rebase -i` is what you want.
Brian Campbell