Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rewriting Git History: How do I remove a sign-off?

Tags:

git

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
like image 843
Mantrum Avatar asked Dec 09 '22 14:12

Mantrum


2 Answers

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.

like image 91
Brian Campbell Avatar answered Dec 20 '22 02:12

Brian Campbell


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.

like image 35
Mantrum Avatar answered Dec 20 '22 01:12

Mantrum