相关疑难解决方法(0)

如何丢弃Git中的未分级更改?

如何放弃工作副本中不在索引中的更改?

git version-control

4562
推荐指数
38
解决办法
242万
查看次数

无法弹出git stash,'您对以下文件的本地更改将被合并覆盖'

所以我有一大堆更改和一些未跟踪的文件.我需要调整一些东西,所以我使用git stash -u,修改了一些东西,提交了这些修改,推动了它们,然后尝试了git stash pop.

因为我修改了一些我藏匿的文件,所以收到了以下消息:

error: Your local changes to the following files would be overwritten by merge:
    file_1.py
    file_2.py
Please, commit your changes or stash them before you can merge.
Aborting
Run Code Online (Sandbox Code Playgroud)

这看起来很奇怪,我已经提交了所有新的更改,当我运行命令时,我的结账很干净.

似乎git stash pop操作没有隐藏我的一半更改和未跟踪的文件,但如果我git stash pop再次尝试,我得到的输出如下:

some_file.html already exists, no checkout
some_other_file.html already exists, no checkout
yet_another_file.html already exists, no checkout
Could not restore untracked files from stash
Run Code Online (Sandbox Code Playgroud)

git stash show 仍然显示了我的藏匿变化列表,但我对我现在所做的事情感到茫然.

我怎么能让自己脱身?

git git-stash

53
推荐指数
2
解决办法
3万
查看次数

为什么git stash pop说它无法从存储条目中恢复未跟踪的文件?

我有一堆阶段性和非阶段性的更改,我想快速切换到另一个分支然后切换回来.

所以我使用以下方式进行了更改:

$ git stash push -a
Run Code Online (Sandbox Code Playgroud)

(事后我可能会用--include-untracked而不是--all)

然后,当我去弹出藏匿处时,我遇到了很多错误:

$ git stash pop
foo.txt already exists, no checkout
bar.txt already exists, no checkout
...
Could not restore untracked files from stash entry
Run Code Online (Sandbox Code Playgroud)

似乎没有从藏匿处恢复任何更改.

我也试过,$ git stash branch temp但显示相同的错误.

我确实找到了解决这个问题的方法:

$ git stash show -p | git apply
Run Code Online (Sandbox Code Playgroud)

现在避免了灾难,但这提出了一些问题.

为什么这个错误首先发生,下次如何避免?

git git-stash

40
推荐指数
5
解决办法
1万
查看次数

如何使用git stash检索未跟踪的文件

所以我用一些未跟踪的文件藏起来

git stash --include-untracked
Run Code Online (Sandbox Code Playgroud)

然后切换到另一个分支.

如果我看看哪些变化被隐藏了:

backend/infinispan-rar/pom.xml                     |   12 ++++++++++--
backend/pom.xml                                    |   13 +++++++++++--
backend/test/pom.xml                               |    3 +--
.../main/resources/com/mojiva/testDbContext.xml    |    6 +++---
data/mojiva.xml                                    |    2 +-
dbmigration/pom.xml                                |   16 ++++++++++------
.../main/resources/db/changelogs/issue-17544.xml   |    4 ++--
pom.xml                                            |   11 +++++++++++
Run Code Online (Sandbox Code Playgroud)

然后我尝试使用检索这些文件

git stash pop
Run Code Online (Sandbox Code Playgroud)

得到这个:

backend/activator/effective.pom already exists, no checkout
backend/adverter/src/test/java/com/mojiva/presenter/RequestParamReplacerTest.java already exists, no checkout
backend/dao/.cpath already exists, no checkout
backend/dao/.e0 already exists, no checkout
backend/dao/PutObjectStoreDirHere/defaultStore/Recovery/TransactionStatusManager/#22#/0_ffffc0a86465_cfd2_5016b5cb_1 already exists, no checkout
backend/dao/dep.tree already exists, no checkout
backend/feeds-test/.e0 already exists, no checkout
backend/feeds-test/dep.tree already …
Run Code Online (Sandbox Code Playgroud)

git

14
推荐指数
3
解决办法
7799
查看次数

标签 统计

git ×4

git-stash ×2

version-control ×1