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

I would recommend never using git checkout to clear local changes, and instead recommend either git stash or git stash -p depending on whether you want to save the whole work tree or just part of it. The stash subcommand internally creates commits for the stashed content, so you can probably also get to them via the reflog, though I haven't personally needed to do this.


If I have local "dirty" state that I need to hold on to, I just hide it in a temp directory like this:

  mkdir temp
  echo '*' >temp/.gitignore
Quick, dirty, effective. :)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: