Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't know much about git but I just do

    git reset --soft HEAD~n 
where n is the number of commits I want to undo.

Known issue: can't undo all the commits.



git reset --hard origin/master just deletes all your local work on the current branch.


I never want that though. If I wanted to do something like that, I'd do the git reset soft, followed by git stash, followed by git switch. I think this at least allows me to look back at it locally?

Git switch is also something I learned recently so sometimes I type checkout because of force of habit but I am trying to do better (even though I'm not sure what switch dies that checkout can't but don't want to get into arguments, just want to do things the prescribed way).


The thing about git is that it's basically plumbing all the way down. In this case: switch abstracts over checkout, which abstracts over read-tree & checkout-index. The nesting doll just keeps going.

Because switch is built on top of checkout, there's no functional difference between the output of the two subcommands when used for the same purpose (assuming the presence of a skilled operator). It's strictly a matter of ergonomics and abstraction.

At the end of the day, as long as you don't fuck up, just do whatever best keeps you in your flow state.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: