gitrebasegpg-signaturegit-interactive-rebase

Best way to sign (-S) each commit during an interactive rebase?


If you are doing an interactive rebase (eg: git rebase -i HEAD~3) and you modify n-2 [aaaa]:

e aaaa commit message for n-2
pick bbbb commit message for n-1
pick cccc commit message for n

After you are done editing (git commit -S --amend), even if you used -S when you committed bbbb and cccc originally, they will no longer be verified because you modified a previous commit. Is there an easier way to sign bbbb and cccc instead of amending every commit in the chain like this:

e aaaa commit message for n-2
e bbbb commit message for n-1
e cccc commit message for n

and running

git commit -S --amend --no-edit && git rebase --continue for each commit?


Solution

  • With Git it's pretty much always a good idea to check for a config that sets it up to work the way you want.

    Found by saying git help config and /commit.*sign:

    git -c commit.gpgsign=true rebase
    

    or just git config --global commit.gpgsign true.