DEV Community

Cover image for Anyone Can Commit Code as You on GitHub (Here's How to Stop Them)

Anyone Can Commit Code as You on GitHub (Here's How to Stop Them)

Nick Taylor on October 26, 2025

I've been signing my Git commits since 2020, and it's one of those security practices that seems optional until you realize how easy it is for some...
Collapse
 
churuz-fyi profile image
Jesu

Doesn't linking git to GH via ssh through the gh-cli automatically do this already or is linking it manually different?

Collapse
 
eklavvya profile image
Rajesh Pethe

Linking git to GH via ssh is needed to authenticate you with GitHub. That's how it determines if you have various rights wrt any repository.

I think, what @nickytonline is talking about is establishing authenticity, integrity and non-repudiation of each commit. No one can misuse your email and impersonate a commit if you sign all your commits.

Collapse
 
nickytonline profile image
Nick Taylor

Exactly Rajesh. Well said and thanks for reading my post!

Collapse
 
nickytonline profile image
Nick Taylor

I wasn’t aware of the GitHub CLi doing this. TIL!

Collapse
 
churuz-fyi profile image
Jesu • Edited

Don't take my word for it. All I know is that the gh CLI let's you sign your local Git from your GitHub account via SSH as how I understand it, I'm only asking if it's the same as signing with a GPG key like you showed.

This is the method I always use to link my Git account to GitHub via SSH but if GPG is different I'll take the time to reauthenticate my accounts.

Thread Thread
 
nickytonline profile image
Nick Taylor

It’s probably different because GPG can be for more than just signing got commits. Will dig in though as I use the GH CLI all the time.

Thread Thread
Collapse
 
hashbyt profile image
Comment deleted
Collapse
 
churuz-fyi profile image
Jesu

I see now. Thank you for the clarification.

Collapse
 
sara_hajbi profile image
Sara Hajbi • Edited

Useful guide!
Thank you

Collapse
 
nickytonline profile image
Nick Taylor

Geordi Laforge in a sweater saying “No problem”

Collapse
 
shemith_mohanan_6361bb8a2 profile image
shemith mohanan

Excellent write-up 👏 — most devs don’t realize how easy it is to spoof commits until it happens.
GPG signing really is the “HTTPS moment” for Git commits — optional now, essential later.
Love how you broke it down step-by-step (especially the macOS GPG Keychain part).
Bookmarking this for every new repo setup. 🔒💻

Collapse
 
nickytonline profile image
Nick Taylor

Thanks for giving it a read Shemith!

Actor Leonardo DiCaprio as Gatsby doing a cheers

Collapse
 
ashbuk profile image
Asher Buk

Thanks for sharing — good OSS practice!

Collapse
 
nickytonline profile image
Nick Taylor

You’re welcome Asher!

Actor Zach Galifianakis giving a thumbs up in a convertible car

Collapse
 
milan_sarkarnnn_5f2e75c55 profile image
milan Sarkarnnn

Ou sou cool

Collapse
 
somadinag profile image
Somadina

Wow, have never considered this at all. It looks unnecessary but it's actually important during contributions. I like how you expatiated the need and also show us how to register and start using it.

From what I realise about your perspective, "gpg" is a seperate application we can integrate with git to GitHub interaction, and it is easy and better for developer.

Thanks any. Will do more rest about it.

Collapse
 
framemuse profile image
Valery Zinchenko

What about open source projects? Everyone must be forced to use signed commits on your repo?

Collapse
 
nickytonline profile image
Nick Taylor

They don't have to necessarily. It's up to the maintainers of the project.

Collapse
 
balavaradhalingam profile image
Balasaranya Varadhalingam

Excellent write-up ; clear, practical, and much needed for dev security hygiene.

Collapse
 
nickytonline profile image
Nick Taylor

Thanks Balasaranya!

Hot Rod saying Cool beans!

Collapse
 
buttercookie profile image
gogogo

It's soo amazing !

Collapse
 
nickytonline profile image
Nick Taylor

Thanks Gogogo!

Amy Poehler being cool

Collapse
 
nelsongarcia01 profile image
Nelson Garcia Dev.

Amazing tips.

Collapse
 
nickytonline profile image
Nick Taylor

You’re welcome Nelson!

Captain America saluting

Collapse
 
parag_nandy_roy profile image
Parag Nandy Roy

Super clear guide...

Collapse
 
parag_nandy_roy profile image
Parag Nandy Roy

Super clear and actionable....

Collapse
 
simon_morley profile image
Simon Morley

Great article! Love learning something new from another old timer :)