Sam
Sam

Reputation: 43

How can I directly edit the PGP signature of a commit?

I'm trying to replicate git commits exactly (with exact matching SHAs) through git commands. I can record the PGP signature, but how could I insert the recorded signature onto a new commit without using gpg?

Here's the original commit that I'd like to replicate:

author s130 <[email protected]> 1559763035 -0800
committer GitHub <[email protected]> 1559763035 -0800
gpgsig -----BEGIN PGP SIGNATURE-----

 ABCDEFGHIJKLMNOP+BhbCRBK7hj9Ov4rIwAAdHIIAHNl2VzESu4fShThzvvK6SV2
 IDnvDnh1aBlIL4acSGzwzegg0Ldkq1/eumYmXxNiRhQYn65UUA59AwMQzKkDostw
 b8lMXyqi/po1q1r6IK6dW3ES9F7hFVVwJuW0ga6XMVNyMhhDVD2KDROO8kx2bIU7
 i/Vv0vFHXFEc/Ui3UPQ+uIMFNJRB2ZbR4hDoHG92251Ba0rExEKmCc2cKEopoG9m
 OxYFEVKAIbJRAsXK29CsljqNrVaMy91vUEjdh5J9bxRLhiGFksMue2NUtk91cVge
 yWkwnStAU6qH8GFmjxT+7Uh674gkjIBsxVznnZsLBH18XvsRsmGSMAsMl3TmhK0=
 =AB0C
 -----END PGP SIGNATURE-----


Initial commit

And here's my attempt at replicating it:

author s130 <[email protected]> 1559763035 -0800
committer GitHub <[email protected]> 1559763035 -0800

Initial commit

The only difference is the lack of a gpgsig header. How can I manually add/edit it?

Upvotes: 1

Views: 127

Answers (1)

bk2204
bk2204

Reputation: 77004

You can synthesize the object yourself and pass it to git hash-object -w, which will hash it and then write it into the database. You can then attach it to a reference (branch, tag, etc.) with git update-ref.

Git doesn't provide a way for you to create an object with an arbitrary signature other than you synthesizing the object yourself.

Upvotes: 2

Related Questions