this post was submitted on 06 Oct 2025
850 points (96.7% liked)

Programmer Humor

27321 readers
1842 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
 

Yeah learned this the hard way.

top 50 comments
sorted by: hot top controversial new old
[–] Ephera@lemmy.ml 139 points 1 month ago (11 children)

I've had juniors who didn't believe this, so just to say it: If you know what you're doing, practically any Git problem is recoverable.

The one major exception is if you delete your local changes before committing them.

[–] sorter_plainview@lemmy.today 52 points 1 month ago (12 children)

Yeah.But many of them are extremely annoying. Specifically screwing up rebase. It is recoverable, but very annoying.

That said I have seen juniors make two other common mistakes.

  1. Pushing your commit without fetching
  2. Continuing on a branch even after it was merged.

I'm fed up with these two. Yesterday I had to cherry-pick to solve a combination of these two.

[–] psycotica0@lemmy.ca 40 points 1 month ago* (last edited 1 month ago) (7 children)

Maybe I'm just a wizard, or I don't know what y'all are talking about, but rebases aren't special. If you use git reflog it just tells you where you used to be before the rebase. You don't have to fix anything, git is append only. See where the rebase started in reflog, it'll say rebase in the log line, then git reset --hard THAT_HASH

Pushing without fetching should be an error. So either they got the error, didn't think about it, and then force pushed, or someone taught them to just always force push. In either case the problem is the force part, the tool is built to prevent this by default.

Continuing after merge should be pretty easy? I'd assume rebase just does it? Unless the merge was a squash merge or rebase merge. Then yeah, slightly annoying, but still mostly git rebase -i and then delete lines look like they were already merged?

[–] sorter_plainview@lemmy.today 19 points 1 month ago (2 children)

See all this is fine for someone with good experience in git. They know how to solve the screw up. But wih junior devs, who don't know much about it, they will just get confused and stuck. And one of the senior has to involve and help them solve. This is just annoying because these can be avoided very easily. Until they understand the pattern of how everyone operates with git, it just creates issues.

To me first time causing this issue is completely fine. I will personally sit with them and explain then what went wrong and how to recover. Most of them will repeat it again, act clueless and talk like they are seeing this for the first time in their life. That is the difficult part to me.

May be I'm just old school, and a grumpy old person, even though I'm not that aged.

load more comments (2 replies)
load more comments (6 replies)
load more comments (11 replies)
[–] panda_abyss@lemmy.ca 8 points 1 month ago (1 children)

All hail the mighty reflog!

Saviour of us all!

load more comments (1 replies)
[–] witness_me@lemmy.ml 5 points 1 month ago

IntelliJ has local history for that case.

load more comments (8 replies)
[–] sik0fewl@lemmy.ca 49 points 1 month ago (14 children)
[–] squaresinger@lemmy.world 31 points 1 month ago

git re-flog is what you do with those idiots who mess up the repo so that someone else has to come in and fix it again.

[–] hayvan@feddit.nl 8 points 1 month ago

Reflog, when flogging isn't enough.

load more comments (12 replies)
[–] QuizzaciousOtter@lemmy.dbzer0.com 47 points 1 month ago* (last edited 1 month ago) (2 children)
  1. Use git for any code you write. Yes, even a simple script.
  2. Commit and push often. More often than you think is reasonable. You can always rebase / fixup / squash / edit but you can't recover what you didn't commit.
  3. ???
  4. Profit.

Seriously, once you commited something to the repo it's hard to lose it. Unless you delete .git. But a this point frequent pushing has your back.

I know git can be hard to grasp in the beginning. It was hard for me too. I highly encourage everyone to put in the effort to understand it. But if you don't want to do that right now just use it. Just commit and push. It will pay off.

[–] Rooster326@programming.dev 8 points 1 month ago* (last edited 1 month ago) (5 children)
  1. (3) Get annoyed by constantly increasing Code Coverage Requirements on untestable (often legacy) code. Even afding comments requires code coverage go up! Line must always go up!
  2. Change step 2 to "Commit and push ONLY when absolutely necessary. Because adding comments often requires a rewrite of untestable code."
  3. Go back to Step 2 and wait for a major bug.
load more comments (5 replies)
load more comments (1 replies)
[–] kibiz0r@midwest.social 31 points 1 month ago (1 children)

Git repository operations are (almost?) always recoverable. git reflog is your friend.

The filesystem operations are another story. Handle with care.

[–] theneverfox@pawb.social 7 points 1 month ago (1 children)

Wait, what does reflog do?

[–] kibiz0r@midwest.social 18 points 1 month ago (1 children)

Think of it like your browser history but for Git. It’s a list of the SHAs related to your recent operations.

And because Git is a content-addressable data store, a SHA is basically like a URL. Even if a branch no longer exists, if you know the SHA it pointed to then you can still check out the exact contents of that branch. The reflog helps you find that.

[–] theneverfox@pawb.social 18 points 1 month ago (4 children)

Goddamit... It's ref log, not re flog. I thought this was related to blame and never touched it lmao

[–] Jankatarch@lemmy.world 9 points 1 month ago* (last edited 1 month ago)

I guess "git sanasaryan-han-torture" was an overkill sometimes...

load more comments (3 replies)
[–] csm10495@sh.itjust.works 29 points 1 month ago (7 children)

Special shout out to the person who committed a gigabyte memory dump a few years ago. Even with a shallow clone, it's pretty darn slow now.

We can't rewrite history to remove it since other things rely on the commit IDs not changing.

Oh well.

[–] Michal@programming.dev 11 points 1 month ago

Sounds like a flawed workflow, if this didn't go through at least code review. Was it committed directly to master?

Curious to know what kind of system relies on hashed not changing? Technically the hashes don't change, but a new set of commits is made. The history diverges, and you can still keep the old master if you need it for some time, even cherry pick patches to it..

load more comments (6 replies)
[–] marcos@lemmy.world 28 points 1 month ago (1 children)

You know... A version control system... That class of software that makes it possible for you to recover from any error you commit.

load more comments (1 replies)
[–] Anafabula@discuss.tchncs.de 26 points 1 month ago (4 children)

With Jujutsu (which is compatible with git), you can just

jj undo
[–] JustTesting@lemmy.hogru.ch 15 points 1 month ago* (last edited 1 month ago)

Been using it for over a year now and not being scared of trying operations is such a boon. It helps so much with learning when you know you can just roll back to an earlier state.

I've had zero issues with it so far and no one at work noticed anything different, other than there being a bit more rebase spam on PRs.

[–] umfk@lemmy.world 9 points 1 month ago (2 children)

That is so cool. Why doesn't git have this already?

[–] kata1yst@sh.itjust.works 10 points 1 month ago

I mean, by definition, it does. It just involves parsing through the git log and a bunch of unintuitive, archaic commands.

load more comments (1 replies)
load more comments (2 replies)
[–] cmhe@lemmy.world 20 points 1 month ago* (last edited 1 month ago) (6 children)

Isn't it the exact opposite?

I learned that you can never make a mistake if you aren't using git, or any other way for having access to old versions.

With git it is really easy to get back to an old version, or bisect commits to figure out what exact change was the mistake.

The only way I understand this joke is more about not wanting to be caught making a mistake, because that is pretty easy. In other methods figuring out who did the mistake might be impossible.

[–] AeonFelis@lemmy.world 14 points 1 month ago* (last edited 1 month ago) (4 children)

This is not about mistakes in the Git-managed code. This is about mistakes in the Git commands themselves. Anything that involves merging/rebasing/conflict resolution can potentially be botched. These mistakes are usually fixable, but:

  1. Fixing it requires some Git proficiency behind the level of the common Git user.
  2. If you don't catch it in time, and only find the mistake when it's deep in your layers of Git history - well, good luck.
[–] LePoisson@lemmy.world 5 points 1 month ago

Went to tech elevator boot camp, was a decent experience even if I don't find myself doing exactly what I was expecting to do. Life is that way though.

Anyways, my first week I fucked some git stuff up so bad I became the go to guy when anyone had any git issues because I had to learn so much to undo my egregious error. I don't remember now exactly what it was but it took some serious git magic to sort.

Just saying that point 1 is very true. And yeah don't make mistakes in git.

load more comments (3 replies)
load more comments (5 replies)
[–] Eiri@lemmy.ca 16 points 1 month ago (4 children)

As long as you never touch the rebase button, you'll be fine. Probably.

[–] GissaMittJobb@lemmy.ml 14 points 1 month ago (6 children)

Don't be afraid of rebases, they are an essential tool in Git.

This particular fear can only be addressed by understanding.

load more comments (6 replies)
[–] pupbiru@aussie.zone 9 points 1 month ago
[–] LedgeDrop@lemmy.zip 6 points 1 month ago (7 children)

... and force push.

If you ever find yourself in a situation where rebase or a force push seems to be the solution, take a step back, clone your repo in a new directory and copy the changes into you're new checkout - 'cause you gon' and screwed somethin' up, son.

[–] witness_me@lemmy.ml 21 points 1 month ago (3 children)

I rebase and force push daily. I like squashing all my commits, and our main branch moves quickly so I rebase off that often. Zero issues for me.

[–] smiletolerantly@awful.systems 8 points 1 month ago (3 children)

Same. And even if you were to fuck up, have people never heard of the reflog...?

Every job I've worked at it's been the expectation to regularly rebase your feature branch on main, to squash your commits (and then force push, obv), and for most projects to do rebase-merges of PRs rather than creating merge commits. Even the, uh, less gifted developers never had an issue with this.

I think people just hear the meme about git being hard somewhere and then use that as an excuse to never learn.

load more comments (3 replies)
load more comments (2 replies)
[–] majster@lemmy.zip 8 points 1 month ago (1 children)

I rebase and force push PR branches all the time. Master is moving quicker than my PR.

load more comments (1 replies)
load more comments (5 replies)
load more comments (1 replies)
[–] borf@lemmynsfw.com 14 points 1 month ago

I don't think you should be scared of git.

Unless by "scared" you mean "I pasted from ChatGPT and now I don't know what to do," in which case, please be more scared.

[–] avidamoeba@lemmy.ca 9 points 1 month ago

Skill issue

[–] goatinspace@feddit.org 8 points 1 month ago (2 children)
load more comments (2 replies)
[–] isVeryLoud@lemmy.ca 6 points 1 month ago

git reflog is your friend

The worst thing you could do is delete your local git repo.

[–] luciole@beehaw.org 6 points 1 month ago (1 children)

We need version control for the version control.

[–] xia@lemmy.sdf.org 8 points 1 month ago

git gud, son

load more comments
view more: next ›