|
|
|
|
|
by enoch_r
4866 days ago
|
|
git reflog
Before I learned that command, I'd seen git as a backup tool with some scary options for manipulating history that I didn't want to touch for fear they'd blow up on me. After learning about git reflog, I finally understood that this was like being scared of pressing backspace on the keyboard. Yes, it can erase commits you really really needed--but all you need to do to get them back is: git reflog
(to find the commit hash you want to get back to), then git reset --hard ${old commit hash}
to get to it.Now, without any reason to fear experimentation, I can use git like it's meant to be used. I can edit my local history without fear, then push it to the remote repo. (One reason to still stay slightly cautious--some git commands run garbage collection automatically, and garbage collection will destroy any disconnected commits. Running "git config --global gc.auto 0" will fix this--I prefer to manage the garbage collection myself anyway, personally.) |
|
Given this grace period, disabling AGC altogether is probably overkill, but there is nothing wrong with that, if it's really what you prefer.