How to delete a stash created with git stash create?

前端 未结 9 986
失恋的感觉
失恋的感觉 2020-12-04 04:28

Git stash seems to do a lot of what I want, except that it is a little hard to script, as the if you have no changes, then git stash; git stash pop will do some

9条回答
  •  攒了一身酷
    2020-12-04 05:17

    You should be using

    git stash save
    

    and not

    git stash create
    

    because this creates a stash (which is a regular commit object) and return its object name, without storing it anywhere in the ref namespace. Hence won't be accessible with stash apply.

    Use git stash save "some comment" is used when you have unstaged changes you wanna replicate/move onto another branch

    Use git stash apply stash@{0} (assuming your saved stash index is 0) when you want your saved(stashed) changes to reflect on your current branch

    you can always use git stash list to check all you stash indexes

    and use git stash drop stash@{0} (assuming your saved stash index is 0 and you wanna delete it) to delete a particular stash.

提交回复
热议问题