Eclipse/Git - 拉取失败的脏工作树

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23599667/
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 18:04:42  来源:igfitidea点击:

Eclipse/Git - Pull Failed Dirty Worktree

eclipsegitide

提问by Ariana

As the title states, I'm attempting to pull from a git repository that I'm sharing between my friend and I and I can commit, he can commit, but whenever either one of us attempt to pull it brings back that it failed: DIRTY_WORKTREE

正如标题所述,我试图从我和我的朋友之间共享的 git 存储库中提取,我可以提交,他可以提交,但是每当我们中的任何一个尝试提取它时,都会提示它失败了: DIRTY_WORKTREE

Both of us are extremely new to git, and have zero direction on how to fix this issue.

我们俩都对 git 非常陌生,并且对如何解决这个问题没有明确的方向。

回答by Clerenz

I was able to fix a similar issue by using the git command line client. While eclipse (egit) was only saying DIRTY_WORKTREE, in the command line I saw multiple conflicting files. Using git merge masterfrom the command line, I could easily resolve the conflicts then in eclipse. So for me this seems to be an egit issue.

我能够通过使用 git 命令行客户端解决类似的问题。虽然 eclipse (egit) 只是说 DIRTY_WORKTREE,但在命令行中我看到了多个冲突的文件。git merge master从命令行使用,我可以轻松解决 eclipse 中的冲突。所以对我来说,这似乎是一个 egit 问题。

回答by VonC

Another approach, if you don't have any work in progress, is to try and reset --hard your HEAD.

另一种方法,如果您没有任何正在进行的工作,则尝试重置 --hard 您的 HEAD。

With EGit: Resetting your current HEAD:

使用 EGit:重置您当前的 HEAD

Select Team -> Reset...on a project. This opens a dialog where you can select a branch or a tag.

选择Team -> Reset...一个项目。这将打开一个对话框,您可以在其中选择分支或标记。

Reset HEAD on your current branch, in order to reset index andworking tree to the last commit of said branch.

在当前分支上重置 HEAD,以便将索引工作树重置为所述分支的最后一次提交。

Then try your pull.

然后试试你的拉力。

回答by ununiform

I had uncommitted changes. After I committed them, then merged, the dirty worktree issue disappeared.

我有未提交的更改。在我提交它们,然后合并之后,肮脏的工作树问题就消失了。

回答by abagri

Just delete the .gitignore present in the project folder, and then merge. The merge will show conflicts , which you need to resolve and then push the changes.

只需删除项目文件夹中存在的 .gitignore,然后合并。合并将显示冲突,您需要解决这些冲突,然后推送更改。

回答by noname

It seems to mean that the version you are on now has edits that are not yet committed. So you either have to remove these edits, or commit them. Notice that if you commit them you may get merge conflicts.

这似乎意味着您现在使用的版本有尚未提交的编辑。因此,您要么必须删除这些编辑,要么提交它们。请注意,如果您提交它们,您可能会遇到合并冲突。

回答by vennapu

Delete the affected files and try to pull again. Thereafter push your changes to the git. I has the same issue and this worked for me.

删除受影响的文件并再次尝试拉取。此后将您的更改推送到 git。我有同样的问题,这对我有用。

回答by psuzzi

In my case, the DIRTY_WORKTREEwas caused by this sequence:

就我而言,DIRTY_WORKTREE是由以下序列引起的:

  1. In a commit, I committed also some files that I should have ignored
  2. In the next commit I modified the .gitignorethat ignore the above files
  3. Try to rebase on top of another branch where my change to .gitignore is missing
  1. 在提交中,我还提交了一些我应该忽略的文件
  2. 在下一次提交中,我修改了忽略上述文件的 .gitignore
  3. 尝试在我对 .gitignore 的更改丢失的另一个分支之上重新建立基础

In this scenario, Eclipse thinks your working tree is dirty. Indeed, it is not obvious comparing two filesets when one of the two is ignoring some files and the other is not.

在这种情况下,Eclipse 认为您的工作树是脏的。实际上,当两个文件集之一忽略某些文件而另一个不是 时,比较两个文件集并不明显。

To solve the issuein Eclipse, I did the following:

为了解决Eclipse 中的问题,我执行了以下操作:

  • Modify the .gitignore so it is the same as the one in the branch I want to rebase on
  • Happily start the rebasing or rebasing with merge.
  • 修改 .gitignore 使其与我想要重新建立的分支中的相同
  • 愉快地开始变基或变基与合并。

回答by Sergio López Casta?o

If you have changes without commiting, eclipse will advise you if you try to pull changes. To solve it, you can discard the changes or do the commit of these files.

如果您在没有提交的情况下进行了更改,如果您尝试拉取更改,eclipse 会建议您。要解决它,您可以放弃更改或提交这些文件。

Source: https://www.eclipse.org/forums/index.php?t=msg&th=890477&goto=1565668&#msg_1565668

来源:https: //www.eclipse.org/forums/index.php?t=msg&th=890477&goto=1565668&#msg_1565668

回答by LadyQ

If you want to override you local branch to the origin branch.

如果要将本地分支覆盖到原始分支。

Go to Git repo view> click on origin master> Choose reset ->it will show current HEAD and resetting to branch. Choose HARD reset, if you want to completely overwrite your local changes

转到 Git repo 视图> 单击 origin master> 选择 reset -> 它将显示当前 HEAD 并重置为分支。如果要完全覆盖本地更改,请选择 HARD reset

回答by mahesh reddy

This error is happening when you have made local changes to files that haven't been committed yet. In git's parlance, you have uncommitted changes in your working tree.

当您对尚未提交的文件进行本地更改时,就会发生此错误。用 git 的话来说,您的工作树中有未提交的更改。

When you are in this situation and you try to pull, git is not sure what to do with the local changes you have. Should it discard those and pull the changes from the remote? Should it commit those beforepulling the changes from the remote? That's why it fails.

当您处于这种情况并尝试拉取时,git 不确定如何处理您拥有的本地更改。它应该丢弃那些并从遥控器中提取更改吗?它应该从远程拉取更改之前提交那些吗?这就是它失败的原因。

To avoid this problem before you pull changes into your local repository you either have to commit your local changes, stash them, or discard them. Once you don't have pending local changes in your working tree, you should be able to pull with no errors.

为了在将更改拉入本地存储库之前避免此问题,您必须提交本地更改、存储它们或丢弃它们。一旦您的工作树中没有待处理的本地更改,您应该能够正确拉取。