Reputation: 755
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
Both of us are extremely new to git, and have zero direction on how to fix this issue.
Upvotes: 35
Views: 87908
Reputation: 11
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.
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 before pulling the changes from the remote? That's why it fails.
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.
Upvotes: 1
Reputation: 9
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
Upvotes: 0
Reputation: 1
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.
Source: https://www.eclipse.org/forums/index.php?t=msg&th=890477&goto=1565668&#msg_1565668
Upvotes: 0
Reputation: 2277
In my case, the DIRTY_WORKTREE was caused by this sequence:
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.
To solve the issue in Eclipse, I did the following:
Upvotes: 0
Reputation: 45
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.
Upvotes: 0
Reputation: 11
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.
Upvotes: 1
Reputation: 141
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.
Upvotes: 1
Reputation: 89
I had similar problem on Eclipse with uncommited changes as ununiform. After a commited I could merge and everything is back as it should be. Take a look at your source code and check any changes. If none you can reset hard.
Upvotes: 0
Reputation: 3774
Only to add another case, I've got DIRTY_WORKTREE, I'm the only one commiting to my Github project, so in EGit I did a Push branch... with "Force overwrite of branch on remote if it exists and has diverged"
DANGER: If other are working on the same project, this action will delete their commits since divergence.
Upvotes: 0
Reputation: 436
I had uncommitted changes. After I committed them, then merged, the dirty worktree issue disappeared.
Upvotes: 11
Reputation: 1
I think this problem is caused by EGit version. When I used Spring Tools Suite with EGit 2.6, I also faced same problems.
EGit is included in STS Default package, so EGit upgrade is very difficult.
Currently I am using eclipse WTP with EGit 3.7, this problem is disappeared.
Upvotes: -2
Reputation: 498
In eclipse I went to Team Synchronizing View and from there right clicked on my project and hit 'overwrite' to overwrite all local changes. Then retry your merge.
Upvotes: 0
Reputation: 851
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 master
from the command line, I could easily resolve the conflicts then in eclipse.
So for me this seems to be an egit issue.
Upvotes: 15
Reputation: 1324606
Another approach, if you don't have any work in progress, is to try and reset --hard your HEAD.
With EGit: Resetting your current HEAD:
Select
Team -> Reset...
on a project. This opens a dialog where you can select a branch or a tag.
Reset HEAD on your current branch, in order to reset index and working tree to the last commit of said branch.
Then try your pull.
Upvotes: 13