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?
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.
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.
git reflog
Reflog, when flogging isn’t enough.
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.
Fuck, you beat me to it
Rebase the comment chain and force push!
The number of times I get the compulsion to perform git operations in daily life is disturbing
You’re seeing the matrix.
I hear people praise
git reflog
a lot, but when do y’all use this? Most I’ve ever needed isgit 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 usegit reflog
to go back to Friday for that local branch right? Is that the idea?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.
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.
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.
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.
When I’m not using
git reflog
, it is only because I a’m not making big enoughgit
screw ups.It’s mostly for undoing a rebase or merge you’re not happy with.
I really only need it when I done fucked up.