我刚刚升级了Git。我使用的是Git 1.8.3版本。

今天早上,我想把零钱取出来。

我运行git stash pop stash@{1},得到这个错误。

致命:模糊参数“stash@1”:未知的修订或路径未在 工作树。 使用'——'将路径与修订分开,如下所示: “git[…——[…]’

我已经尝试了大约20个以上的变化,以及使用apply而不是pop,没有成功。是什么改变了?有人遇到过这种情况吗?


当前回答

正如罗伯特指出的那样,引号可能对你有用:

git stash pop stash@"{1}"

其他回答

如果你想确保不必处理语法stash@{x}的引号,请使用Git 2.11(2016年Q4)。

参见Aaron M Watson (watsona4)提交a56c8f5(2016年10月24日)。 (由Junio C Hamano—gitster—在commit 9fa1f90中合并,2016年10月31日)

stash: allow stashes to be referenced by index only Instead of referencing "stash@{n}" explicitly, make it possible to simply reference as "n". Most users only reference stashes by their position in the stash stack (what I refer to as the "index" here). The syntax for the typical stash (stash@{n}) is slightly annoying and easy to forget, and sometimes difficult to escape properly in a script. Because of this the capability to do things with the stash by simply referencing the index is desirable.

So:

git stash drop 1
git stash pop 1
git stash apply 1
git stash show 1

正如罗伯特指出的那样,引号可能对你有用:

git stash pop stash@"{1}"

更新

在git 2.11中只使用数字:

git stash apply 1

包括哪些

在Windows Powershell上运行:

git stash apply "stash@{1}"

这个答案我已经在这个列表中见过几次了,但是为了明确起见,至少从git 2.33.0版本开始,git stash pop stash@{n}是有效的。没有必要逃跑。

我已经安装了2.22,这个工作。

git stash pop --index 1