撤销 "git stash --patch"

3

我执行了“git stash -p”(等同于“git stash --patch”),成功地存储了我对代码所做的一部分更改。当我尝试运行“git stash pop”时,它给了我以下信息:

error: Your local changes to the following files would be overwritten by merge:

[list of files]

Please, commit your changes or stash them before you can merge.

Aborting

我应该如何获取所有更改?这个问题似乎有一个方法(还没有尝试),但我希望有更简洁和简单的方法。

1个回答

3
我也遇到了同样的问题。这是我所做的事情:
$ git stash --patch
# now you have a 'partial' stash
#
# commit all changes in your working tree
$ git add .
$ git commit -m TEMP
# pop the stash
$ git stash pop
# now your stashed changes have been applied successfully
#
# reset your working tree to the original state
$ git reset --soft HEAD^^
# optionally reset your index
$ git reset .

这将重置你的工作树到 git stash 之前的状态。你对索引的更改将会丢失。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接