Git stash pop- 需要合并,无法刷新索引

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9739352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:13:38  来源:igfitidea点击:

Git stash pop- needs merge, unable to refresh index

gitgit-stash

提问by RandallB

I can't pop my stash because I merged a branch which apparently conflicts with my stash and now my stash is seemingly unable to be popped.

我无法弹出我的藏匿处,因为我合并了一个显然与我的藏匿处冲突的分支,现在我的藏匿处似乎无法弹出。

app.coffee: needs merge
unable to refresh index

Anyone know how to resolve this?

有谁知道如何解决这个问题?

FIXED!

固定的!

Turns out the actual issue was an unresolved merge conflict from the merge, NOTthat the stash would cause a merge conflict.

事实证明,实际问题是合并中未解决的合并冲突,而不是存储会导致合并冲突。

Resolution: Commit the conflicted file.

解决方法:提交冲突的文件。

采纳答案by VonC

First, check git status.
As the OP mentions,

首先,检查git status
正如 OP 所提到的,

The actual issue was an unresolved merge conflict from the merge, NOT that the stash would cause a merge conflict.

实际问题是合并中未解决的合并冲突,而不是存储会导致合并冲突。

That is where git statuswould mention that file as being "both modified"

那就是git status提到该文件为“ both modified”的地方

Resolution: Commit the conflicted file.

解决方法:提交冲突的文件。



You can find a similar situation 4 days ago at the time of writing this answer(March 13th, 2012) with this post: "‘Pull is not possible because you have unmerged files'":

您可以在 4 天前在撰写此答案时(2012 年 3 月 13 日)通过以下帖子找到类似的情况:“因为您有未合并的文件,所以无法进行拉取”:

julita@yulys:~/GNOME/baobab/help/C$ git stash pop
help/C/scan-remote.page: needs merge
unable to refresh index

What you did was to fix the merge conflict (editing the right file, and committing it):
See "How do I fix merge conflicts in Git?"

您所做的是修复合并冲突(编辑正确的文件并提交):
请参阅“如何在 Git 中修复合并冲突?

What the blog post's author did was:

博客文章的作者所做的是:

julita@yulys:~/GNOME/baobab/help/C$ git reset --hard origin/mallard-documentation
HEAD is now at ff2e1e2 Add more steps for optional information for scanning.

I.e aborting the current merge completely, allowing the git stash popto be applied.
See "Aborting a merge in Git".

即完全中止当前合并,允许git stash pop应用。
请参阅“在 Git 中中止合并”。

Those are your two options.

这是你的两个选择。

回答by knocte

I was having this issue, then resolving the conflict and commiting, and doing git stash popagain was restoring the same stash again (causing the same conflict :-( ).

我遇到了这个问题,然后解决了冲突并提交,再做git stash pop一次是再次恢复相同的存储(导致相同的冲突:-()。

What I had to do (WARNING: back up your stash first) is git stash dropto get rid of it.

我必须做的(警告:首先备份你的藏品)是git stash drop摆脱它。

回答by ayushgp

Its much simpler than the accepted answer. You need to:

它比接受的答案简单得多。你需要:

  1. Check git statusand unmerged paths under it. Fix the conflicts. You can skip this step if you'd rather do it later.

  2. Add all these files under unmerged paths to index using git add <filename>.

  3. Now do git stash pop. If you get any conflicts these will again need to be resolved.

  1. 检查git status并取消合并它下的路径。修复冲突。如果您想稍后再做,可以跳过此步骤。

  2. 使用 将所有这些文件添加到未合并路径下的索引git add <filename>

  3. 现在做git stash pop。如果您遇到任何冲突,这些将再次需要解决。

回答by StevieJayCee

If anyone is having this issue outside of a merge/conflict/action, then it could be the git lock file for your project causing the issue.

如果有人在合并/冲突/操作之外遇到此问题,则可能是您的项目的 git lock 文件导致了该问题。

git reset
     fatal: Unable to create '/PATH_TO_PROJECT/.git/index.lock': File exists.
rm -f /PATH_TO_PROJECT/.git/index.lock
git reset
git stash pop

回答by Adam

Here's how I solved the issue:

这是我解决问题的方法:

  • git status (see a mix of files from a previous stash, pull, stash pop, and continued work.)
  • git stash (see the needs merge issue)
  • git add . (add the files so my work locally resolves my own merged)
  • git stash (no error)
  • git pull (no error)
  • git stash pop (no error and continue working)
  • git status(查看来自之前的 stash、pull、stash pop 和继续工作的文件的混合。)
  • git stash(请参阅需求合并问题)
  • git 添加。(添加文件,以便我的工作在本地解决我自己的合并问题)
  • git stash(没有错误)
  • git pull(没有错误)
  • git stash pop(没有错误并继续工作)

回答by Julian Tellez

I have found that the best solution is to branch off your stash and do a resolution afterwards.

我发现最好的解决方案是分出你的藏匿处,然后再做一个决议。

git stash branch <branch-name>

git stash branch <branch-name>

if you drop of clear your stash, you may lose your changes and you will have to recur to the reflog.

如果你不清除你的藏匿处,你可能会丢失你的更改,你将不得不重新回到 reflog。

回答by edvard_munch

You need to add app.coffeeto staging.

您需要添加app.coffee到暂存区。

Do git add app.coffeeand then you will be able to apply your stash (after that commit and push).

这样做git add app.coffee然后你就可以应用你的存储(在提交和推送之后)。

回答by Vinodagouda Patil

The stash has already been applied to other files.

存储已应用于其他文件。

It is only app.coffeethat you have to merge manually. Afterwards just run

只是app.coffee您必须手动合并。之后只需运行

git reset

重置

to unstage the changes and keep on hacking.

取消更改并继续黑客攻击。