News for hackers. Stuff that matters.
Re:Oh Shit, Git? by jaapz on Thursday January 16, 2025 @05:27PM (#42731713)
Could you motivate why you suggest these? Why is `switch` better than `checkout`? And why not use `reset --hard`?
Re:Oh Shit, Git? by jopicornell on Thursday January 16, 2025 @06:09PM (#42732089)
Not comment OP, but checkout has two very different uses merged into one: restoring files and switching branches. To not break compatibility, git has now switch and restore commands that make commands more readable and understandable.

You should avoid reset --hard because it will delete all your uncommited, and you could end up in situations where that's really bad. Using reset --keep will keep uncommited changes, and failing if any uncommited change cannot be kept.

Re:Oh Shit, Git? by teaearlgraycold on Thursday January 16, 2025 @10:32PM (#42733805)
I just do

    git add -A

    git stash

    git reset --hard

    git stash pop