4 ms·
I really don't think git reset --hard should be at the top of a list of git commands intended for beginners.
by saila 7y ago
I really don't think git reset --hard should be at the top of a list of git commands intended for beginners.
- 3fe9a03ccd14ca5 7y agoBeginners use this command all of the time when they back themselves against a wall and can’t get out. It’s nice to have an escape ladder when you’re beginning.
- mixmastamyk 7y agoYes, knowing “just enough to be dangerous” is a thing and this article just doused it with gasoline.
- m4r35n357 7y agoand yet is one of the most useful commands for fixing mistakes made by beginners . . .
- u801e 7y agoThough it would probably be better to tell beginners to run git stash save first. Then they wouldn't lose changes they made to the files before running a hard reset.
- _pmf_ 7y agoThe alternative for a beginner is rm -rf repo && git clone repo How is that better?
- cryptonector 7y ago"Someone told me git reset --hard. Oh shit!!! My extant work is all gone!" "Hmm, how to start from scratch? I guess I could save a few files, delete the workspace with good old trusty rm -rf, clone again, and restore those few files." If you can't see the difference between those two... Yes, the Git power user will know how to "start from scratch" without really starting from scratch and without losing extant work they'd rather save. And beginner users can do the second of the above. But teach a beginner to use git reset --hard and they'll hate Git and they'll hate you.
- _pmf_ 7y agoOK, good point.
- Matthias247 7y agoIdeally disable force pushes on master branches of a repo to prevent people who screw up to also also break upstream. You can still lose some work, but at least not the complete repo.