如何在同一个命令中应用并删除我最新的git stash?

时间:2012-07-05 20:04:23

标签: git

看来,当我执行git stash apply时,我需要输入git stash drop以便从可用的存储中删除该存储。我可以在一个命令中执行此操作吗?

1 个答案:

答案 0 :(得分:7)

git stash pop正是您正在寻找的。正如man page所说:

pop [--index] [-q|--quiet] [<stash>]

    Remove a single stashed state from the stash list and apply it on
    top of the current working tree state, i.e., do the inverse operation
    of git stash save. The working directory must match the index.

    Applying the state can fail with conflicts; in this case, it is not
    removed from the stash list. You need to resolve the conflicts by hand
    and call git stash drop manually afterwards.