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

Programmer Humor

26772 readers
1181 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.

you are viewing a single comment's thread
view the rest of the comments
[–] sik0fewl@lemmy.ca 49 points 2 days ago (4 children)
[–] squaresinger@lemmy.world 30 points 2 days 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 7 points 2 days ago

Reflog, when flogging isn't enough.

[–] SpaceNoodle@lemmy.world 4 points 2 days ago (1 children)
[–] panda_abyss@lemmy.ca 10 points 2 days ago (1 children)

Rebase the comment chain and force push!

[–] SpaceNoodle@lemmy.world 6 points 2 days ago* (last edited 2 days ago) (1 children)

The number of times I get the compulsion to perform git operations in daily life is disturbing

[–] Phoenix3875@lemmy.world 3 points 2 days ago

You're seeing the matrix.

[–] Primer81@lemmy.zip 2 points 2 days ago (7 children)

I hear people praise git reflog a lot, but when do y'all use this? Most I've ever needed is git log --graph for history checking. Maybe if I was in a situation where I knew the code on local branch X was working on Friday, but not anymore on Monday, then I could use git reflog to go back to Friday for that local branch right? Is that the idea?

[–] Slotos@feddit.nl 13 points 2 days ago

Power users rebase with squashes and fixups multiple times a day. Especially if the job’s integration process isn’t enforcing long living branches.

Reflog is useful then, because you literally rewrite history every rebase.

[–] chaos@beehaw.org 4 points 2 days ago

I only use it when I've royally messed up and the commit I need to get back is no longer referenced anywhere. Accidentally deleted a branch, finished a merge or rebase before realizing I messed up, that kind of thing, just use the reflog to find it again, get a branch pointing to it, then try again.

[–] panda_abyss@lemmy.ca 5 points 2 days ago

It’s not often, but a bad git reset, or a messed up rebase of that branch that’s 8 months old that you’ve picked up again.

[–] psycotica0@lemmy.ca 3 points 2 days ago* (last edited 2 days ago)

git log will only show you commits in your history. If you're only ever working forwards, this will contain all the stuff you'll ever need.

But if you're rewriting history, like with a rebase or squash or something, or you're deleting branches without merging them, then you can run into a situation where the official history of your branch doesn't contain some of the commits that used to exist, and in fact still exist but are unlinked from anywhere. So reflog is the log of where you've been, even if where you've been isn't in the official history anymore, so you can find your way back to previous states even if there isn't otherwise a name for them.

If all you care about is your current history, git can use the dates of commits just fine to see where you were on Thursday without needing the reflog.

[–] pinball_wizard@lemmy.zip 2 points 2 days ago* (last edited 2 days ago)

When I'm not using git reflog, it is only because I a'm not making big enough git screw ups.

[–] GissaMittJobb@lemmy.ml 1 points 2 days ago

It's mostly for undoing a rebase or merge you're not happy with.

[–] SpaceNoodle@lemmy.world 1 points 2 days ago

I really only need it when I done fucked up.