Retroactively sign git commits

后端 未结 3 534
既然无缘
既然无缘 2021-01-13 07:19

Recent versions of git (>= 1.7.9) support signing individual commits with GPG.

Is it possible to retroactively sign all commits within a tree?

3条回答
  •  借酒劲吻你
    2021-01-13 07:48

    You could try creating a new branch from the point where you want to start signing your commits. I recently did that for a branch that I created on a machine without access to my private key:

    # git checkout -b new-branch 
    # git cherry-pick 
    # git checkout unsigned-branch
    # git rebase new-branch
    

    This requires that your Git is configured to automatically sign your commits, and there obviously shouldn’t be too many merge commits, other the rebase will look weird. If in doubt, cherry-pick your commits; each picked commit will then be signed.

提交回复
热议问题