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

stash is something that should be used for only the briefest of times - the only time I use it is "stash, pull, unstash"

If you want to save partial work to a branch, commit it, go do your work on the other branch, then use "reset --soft HEAD^" to undo the commit but keep the work.

Far more reliable



Why? I stash often and it has been quite reliable for me.


primarily, if you come back to a stash a week later, other than your memory, what tells you what branch that stashed code belongs to?

If somebody else needs to take over the project and pulls the branch, what tells him there's also stashed code for it?

stashes should be very short-lived, they're the wrong tool for anything else


I agree that stashes should be short-lived, but

  % git stash list
will show you what branch was checked out when you stashed. Also, because a stash is represented as a commit, you can know what commit the stash is based on. From the git-stash man page:

"A stash is represented as a commit whose tree records the state of the working directory, and its first parent is the commit at HEAD when the stash was created. The tree of the second parent records the state of the index when the stash is made, and it is made a child of the HEAD commit. The ancestry graph looks like this:

         .----W
        /    /
  -----H----I
where H is the HEAD commit, I is a commit that records the state of the index, and W is a commit that records the state of the working tree."




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

Search: