DEV Community

Cover image for How to get somebody fired using Git

How to get somebody fired using Git

Mauro Accorinti on April 02, 2024

This is Billy. He is a trainee developer working for an important company. Unfortunately for the company, today Billy has woken up and...
Collapse
 
pshaddel profile image
Poorshad Shaddel

Poor Trent should have been familiar with git reflog :) Nice article!

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thank you so much!

Git reflog would have definetely saved the day here

Collapse
 
ethanwillingham profile image
Ethan Willingham

This article is genius, sucked me in with entertainment and actually got me to read something and become informed, thankyou!

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Let's goooo, glad it helped and you enjoyed it!

Collapse
 
kquiggins profile image
Kenneth Quiggins

Adding lessons in with a sense of humor, I love it. 😎

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thanks Kenneth! The world needs fun git tutorials hahaha

Collapse
 
kquiggins profile image
Kenneth Quiggins

It most definitely does my friend πŸ™

Collapse
 
thawkin3 profile image
Tyler Hawkins

That was great, thanks for the laugh! Well written.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thanks for the kind comment!

Collapse
 
wiktorwandachowicz profile image
Wiktor Wandachowicz

That's why everybody and their dog should not use plain --force because it may be destructive.

Instead always use git push --force-with-lease (!)

Found this little gem while watching "So You Think You Know Git - FOSDEM 2024" on YouTube, around 17:42. There is even part 2 of this video 😊

See:

Collapse
 
sin_noariaaisin_2849 profile image
Sin No Aria (AI Sin)

Out of curiosity, is there a reason why they aren't flipped? Like why it wasn't designed with force being force with lease by default and the current force being a force without lease command?

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

So after a few google searches, I honestly couldn't find the answer! So I just went into the Git repository and went down to a tag made 20 years ago.

Here's the git push documentation from that moment:
github.com/git/git/blob/v0.99/Docu...

My guess is git push was made first and then somewhere down the line the option to push with lease was added later.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thank you for mentioning it! The resources you posted are also excellent so it adds a lot.

Thanks to you and another commenter, I decided to at least mention it in the article.

Collapse
 
jankapunkt profile image
Jan KΓΌster

If a previous commit is stable and you messed up things a lot (not necessary due to wrong git usage) then git reset --hard <commit hash> may be exactly what you need

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Oh absolutely! There's a use case and everything for git reset. Especially when you know what you're doing. Git is super powerful for that reason.

Git push - -force also has its uses. It's necessary for doing a clean rebase or when you want to cleanly amend a commit.

It's all about responsible use.

This article was about irresponsible use πŸ˜…

Collapse
 
jankapunkt profile image
Jan KΓΌster

The article is great! Just wanted to leave this one to make people curious. I also love converting on these kind of articles, finding gems I never heard/read before πŸ‘

Collapse
 
spo0q profile image
spO0q • Edited

Congrats for this article. Pretty fun. In real conditions, sign your commits + protect main branches against forced push.

Pull requests can also mitigate those issues (which is mentioned in the post)

Collapse
 
mikec711g profile image
Michael Casile

Creative way to provide some serious DON'Ts and why

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thank you for the kindness!

Collapse
 
joao9aulo profile image
JoΓ£o Paulo Martins Silva

The best way to learn, doing wrong things.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

There's no better way to learn πŸ˜„

Collapse
 
segudev profile image
Thomas Segura • Edited

Great article.
For reference, when a .env file is pushed to public GitHub, it is 54% likely to expose a secret (and it happens a lot..)
source: The State of Secrets Sprawl 2024

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Awesome stat! Really liked the phrase:
β€œCompromised credentials are a gift that keeps on giving
(your stuff away)”

Collapse
 
schollii profile image
schollii

Fun article, if a little evil. One clarification: git reset alters the commit history in your local repository only. If it no longer matches the history on the remote, you will need to use a forced push; regular push will fail.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Oh shoot! You're totally right. You're the first person to bring that up πŸ˜„

I updated the line. Thanks for making Billy a better developer!

Collapse
 
erasmuswill profile image
Wilhelm Erasmus

Now Billy can be the hero by using the distributed architecture and his newly-found git-fu to magically save everyone's work.
Perhaps he will also pin some bugs on Trent: github.com/jayphelps/git-blame-som...

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

This is MASTERFUL. I love how this project even exists.

And maybe! Now that he's gotten all that evil out of his system, maybe he can put out some good in the world.

Collapse
 
lnahrf profile image
Lev N.

Wild ride, Billy sure is a menace to the companyβ„’.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Oh absolutely. Everybody should worry how he codes if this is his way of learning hahaha

Collapse
 
jerry97 profile image
Jerry

Damn, tricked me into reading an article about git.

Collapse
 
jerry97 profile image
Jerry

Also, I read this in the Stanley Parables narrators voice.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

You know, it was kind of the vibe I was going for.

Plus that man's voice is smooth as butter so it only made the experience better

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Muahahaha

Collapse
 
ayush2832 profile image
Ayush

MaterpieceπŸ˜‚

Collapse
 
softgauresh profile image
softgauresh

Excellent article thanks for sharing

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thank you for reading

Collapse
 
softgauresh profile image
softgauresh

I really like your sense of humour...way of thinking is totally super ...looking forward to collaborate with you ...

Thread Thread
 
softgauresh profile image
softgauresh • Edited

Will take your help in furture definitely...really fan of your post ..looking forward for such a post
Really fan of your post

Collapse
 
marissab profile image
Marissa B

Billy as an agent of chaos was hilarious. Great article.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Super happy you enjoyed it!

Collapse
 
obednyakundi profile image
Obed Nyakundi Paul

lol. It was an amazing read.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thank you!

Collapse
 
bcostaaa01 profile image
Bruno

This made me laugh big time, Billy knows always how to get things done, even getting fired haha! Good read and eye opener for every developer :D

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thank you!

Collapse
 
parimaldesign profile image
Parimal

I hope there were Cameras in place and evidence that shows Trent was just a bit careless and Billy was behind this.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

I mean, if the company doesn't have basic permissions so nobody posts on Main, you think they care enough for cameras? πŸ‘€

Collapse
 
kanish profile image
Kanish Ravikumar

All this time, this wasn't Billy's story, it was Trent's villian origin story

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Trent gonna come back with a vengence and with the git reflog

Collapse
 
shinyjohn0401 profile image
Levi Johnson

This article is excellent! Thank you for the laughs and for reminding us of important work principles. I really enjoy learning from articles that incorporate humor. I'm eager for more laughs and learning. ;)

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Aww thank you Levi! We'll see what else I have cooked up for in the future

Collapse
 
c9hp profile image
C9

This is best git tutorial i ever read.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thank you my kind friend

Collapse
 
starswan profile image
Stephen Dicks

Its a shame you didn't mention git push --force-with-lease which is the correct way to do git force pushes.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

You are absolutely right. I added it as a sort of mention so others know it exists. Added it cause you and another commenter brought it up. Thank you

Collapse
 
valdineisantos profile image
Valdinei dos Santos

Disable send and merge in main branch, only permitted send for feature/Fix/others work branch. This resolve 80% issue problems. Merge only after receive 2 code reviews approved.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Yes, absolutely and completely agree!

Collapse
 
tyisi profile image
TyIsI

Thanks for the laugh! It's giving me BOFH vibes!

(And I just found Enterprise Developer From Hell!)

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

I have never heard of BOFH! I looked over it a bit and yeah I can see it hahaha

Collapse
 
inn0cent_zer0 profile image
inn0cent_zer0

Nice article. Thanks for sharing.

Collapse
 
perisicnikola37 profile image
Nikola Periőić

hahahah nice

Collapse
 
tariqywsf profile image
Tarek Bohdima

enjoyed it till the last line, please keep writing "dumb" articles , it's educative and more important "not boring". and you are natural !

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Aww thank you! I think silly is the better term here but I have been blown away by how much others have enjoyed it. Thanks again

Collapse
 
pindelrio profile image
Pindelrio

Very funny!. We want more Billy stories

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Maybe in the future πŸ˜‰

Collapse
 
sujit-shrc profile image
Sujit Kumar

hahaha...

Collapse
 
greenteaisgreat profile image
Nathan G Bornstein

Absolute god-tier article. This sets a new genre for dev.to

Collapse
 
shricodev profile image
Shrijal Acharya

Love the humor. πŸ™Œ

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thanks!

Collapse
 
greengeko profile image
Rey

LOL, this is scaring me hahaha

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

It's the good kind of scared πŸ˜„

Collapse
 
mrnnabhani profile image
Najm El-Deen Nabhani

I feel more sorry for the on-call than for Trent!

Collapse
 
chandrashekhar profile image
Chandrashekhar Mehta

awesome, humorous explanation!!

Collapse
 
sramek5 profile image
Michal Ε rΓ‘mek

This is exactly why in our company I call for the enforcement of proper security measures in GitHub. Anyway, funny and true story bro! πŸ˜‰

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Absolutely!!! Always have good security measures.

And thank you for the comment πŸ˜„

Collapse
 
ademagic profile image
Miko

hahaha, a git article i enjoyed reading for once

Collapse
 
edydeyemi profile image
Edydeyemi

This was quite fun to read, yet educative as well. Thanks for sharing

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thank you for reading!

Collapse
 
devpriti1 profile image
priti roy

great article!

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thank you!!

Collapse
 
gonemob profile image
Dave Schuster

Love it! It's not worth doing if you can't have some fun (okay, not that kind)!

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Exaaaactly, you get it! hahaha

Collapse
 
deepakhce profile image
deepak-hce

I learned a lot with fun and laugh. Thank you.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thank you for reading!

Collapse
 
muzkaviy profile image
Ozgur

Your article turned the complexity of git commands into a delightful learning experience. Kudos for making technical education so engaging!

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Aww thank you Ozgur!

Collapse
 
spondon profile image
Spondon

one of the best articles i read today, love it!!

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thanks a ton for the love! Appreciate it

Collapse
 
evandon profile image
Nineisten

Not all Billy's wear capes. Amazing article.

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

Thank you for the kindness πŸ˜„

Collapse
 
osnipso profile image
Osni Oliveira

Remote work would have prevented Billy from doing it all, just saying... =D

Collapse
 
mauroaccorinti profile image
Mauro Accorinti

That is SUCH a good point though!!

Viva la revoluciΓ³n for remote work hahaha

Collapse
 
mahbod profile image
Mahbod Ahmadi

The only thing Trent must do is set password for his laptop.

Collapse
 
sin_noariaaisin_2849 profile image
Sin No Aria (AI Sin)

Google github prophecy?