Answers:
使用git checkout
代替git stash apply
:
$ git checkout stash -- .
$ git commit
这会将当前目录中的所有文件还原到其隐藏版本。
如果对工作目录中的其他文件进行了更改,则应保留这些更改,这是一种比较宽松的选择:
$ git merge --squash --strategy-option=theirs stash
如果索引中有更改,或者合并将接触具有本地更改的文件,则git将拒绝合并。可以使用以下方式从存储中检出单个文件:
$ git checkout stash -- <paths...>
或与
$ git checkout -p stash
git checkout stash -- .
当我运行该命令时,它实际上什么也没做。
git checkout stash -- .
在包含所做更改的最高父文件夹中运行,否则它将仅将更改应用于我运行命令的文件夹。
.
指定了当前目录(您可以使用其他路径替换它,而不必更改目录)。我更新了我的答案以使其更清楚。
强制git stash pop
运行此命令
git stash show -p | git apply && git stash drop
TL; DR:
git checkout HEAD path/to/file
git stash apply
长版:
由于要覆盖未提交的更改,因此收到此错误。使用撤消这些更改git checkout HEAD
。您可以使用撤消对特定文件的更改git checkout HEAD path/to/file
。消除冲突原因后,您可以照常申请。
git rm
在执行操作之前,使用删除新文件git stash apply
。