3 ms·
checkout is one of the few git commands that makes sense to me. I use it a lot, to get back to a known state, after I screw up my working files with other git c
by SoftTalker 2y ago
checkout is one of the few git commands that makes sense to me. I use it a lot, to get back to a known state, after I screw up my working files with other git commands. E.g.
Copy my changed files to a temporary directory.
Delete my working directory.
Checkout the latest version from the repo.
Copy my changed files back.
- hmcdona1 2y agoUse `git stash` instead of copying files around manually to save yourself some time.
- bluedevilzn 2y agoParent comment is the quintessential example from the article that most people who know git didn't learn git properly.
- SoftTalker 2y agoYeah git rubbed me the wrong way from the beginning and I never learned it properly. My way makes the most sense to me. Stash? where? How do I get my files back? None of that is intuitive. I understand my way.
- camtarn 2y agoI love git stash, but to be fair, if you've just had Git do something unexpected to your files, I can completely understand why you would not then trust Git to keep your changes safe while you use more Git commands to get back into a sane state! Sometimes simple and well understood is the best way.
- seba_dos1 2y agoAnything can do something unexpected to your files if you don't put effort to understand it. Sure, some things require less and some more effort, but using tools without understanding them, while isn't impossible, isn't exactly a recipe for good outcomes.
- mschuster91 2y agoNow if git stash would support only stashing one specific file...
- Izkata 2y agogit stash -- filename
- GeneralMayhem 2y agoor git stash push <filename>
- lukeschlather 2y agoThe article says that git checkout confuses things that could be better accomplished with one of (git restore, git switch, git reset) What you're doing sounds like git reset/git switch would be fine. I think I'm in favor of what the author suggests, conflating switch and reset/restore seems bad. It's going to take some effort to fix my habits though.
- fhars 2y agoThe one bad point about checkout is that is one of the few git commands that can destroy data irretrievably, even without --force or -f or so. That is unexpected behaviour.
- remram 2y agoWhat you want is 'git reset --mixed'