this post was submitted on 07 Feb 2025
305 points (99.0% liked)

Programmer Humor

20352 readers
1560 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] muntedcrocodile@lemm.ee 27 points 6 hours ago (5 children)

That's not a mistake git can do that to people. Especially those who have never used git via command line.

[–] NocturnalMorning@lemmy.world 7 points 6 hours ago* (last edited 6 hours ago) (4 children)

Yeah, imagine you accidently commit over weeks of work, or hell, if it's the main branch, and you deleted the other origin branch prior to merging, it could be a lot more than a few weeks worth of work. The revert to a previous commit... shutters.

[–] WimpyWoodchuck@feddit.org 11 points 5 hours ago (1 children)

I don't know if you're joking, but in case you're not: git reflog and git reset --hard HEAD@{n} is your friend. You can undo almost anything. Deleted commits and branches aren't really deleted. Remotely deleted branches can be pushed again.

Except for an (accidental) git restore/git reset. Those are permanent and can't be undone.

[–] rooroo@feddit.org 3 points 3 hours ago* (last edited 3 hours ago)

Even git reset can be undone by a lot of editors. At least IntelliJ has an excellent local history that works much like git. Sure it’s a pain if you touched several files but that’ll teach you to atomify your commits.

Edit: Plus, git reset itself does nothing of note really, but I’m sure you know. Needs the —hardflag to do any meaningful damage.

load more comments (2 replies)
load more comments (2 replies)