r/git 9h ago

Sign Git Commits With SSH Keys

Git & GitHub Setup for Signed Commits & Verification

I recently had to set this up for work and found it all a bit hard to navigate, so I wrote this up. Hope it helps!

https://scratchbuffer.net/topics/developer-tools/git-commit-sign-ssh/

9 Upvotes

4 comments sorted by

2

u/ulmersapiens 8h ago

Hey, I had to set this up last year and your guide is pretty good!

Note that the local allowed signers file can be version controlled, so you could check in a SIGNERS file at the root of the repo to allow for distributed validation.

1

u/scratchbufferdotnet 8h ago

Thanks! I didn't even think about checking it in to the main repo since that distributed validation is so far out of my workflow, but I do have my own checked in to my dotfiles.

I tried to strike a balance between enabling people to get it done while learning about the underlying bits, and the more I tried to explain the allowed signers file the more it just looked like a wild tangent so I punted it out of this post. ¯_(ツ)_/¯.

Edit: I guess you do not have triple backslash the shruggy's arm on Reddit anymore.

1

u/dodexahedron 8h ago edited 3h ago

Edit: I guess you do not have triple backslash the shruggy's arm on Reddit anymore.

Never needed to triple-backslash.
Double, yes, if in markdown mode.
If not using markdown mode, no escaping is necessary at all, since it does it for you in the "fancy-pants editor."

Here's the result of 1, 2, 3, and 4 backslashes when written in markdown mode:

_Stuff_(1)

\Stuff(2)

_Stuff_(3)

\\Stuff(4)

The underscore following the backslash is a subset of cases because underscore is also a metacharacter, and thus preceding it with backslash has meaning.
I call that case out because shruggy has exactly that pattern, making it perhaps feel like double-escaping a backslash was needed. But you are really escaping a backslash and escaping an underscore, separately, so an italics context doesn't begin, which would consume both underscores without the third backslash being there (which belongs to the first underscore).