34

I am currently working on a java project and when committing my changes and pulling I get the following error. I don't know how to resolve it:

Dirty worktree, eclipse

I tried everything, but can't seem to fix the problem, can someone please help me?

To be clear, I am using eclipse.

Cœur
  • 37,241
  • 25
  • 195
  • 267
n00b1990
  • 1,189
  • 5
  • 17
  • 25

9 Answers9

59

Delete the affected files and try to pull again. Thereafter push your changes to the git.

kds
  • 28,155
  • 9
  • 38
  • 55
10

below steps may help

  1. delete non-versioned files git clean -df

  2. reset your local changes

    git fetch git reset --hard

Mohannad
  • 111
  • 1
  • 4
6

I got the same error while trying to merge the code. Delete the respective file in either of the branches to merge DIRTY_WORKTREE FAILED

Vamsi Ravi
  • 1,196
  • 8
  • 26
1

Assuming your working in a local branch, that is branched from a remote branch, and the merge conflict is occurring after you 'commit and push' upstream, merge to remote branch.

Try these 3 steps:

  1. Copy off the new changes from the specific file causing the merge issue.
  2. In Eclipse, Explorer pane, rt-click on the specific file causing the merge issue, and select replace with previous revision.
  3. Now perform a 'commit and push'
  4. Perform a merge to remote branch (no conflict should be observed).
  5. In Eclipse, rt-click on the specific file again, and select 'pull' - the file should now be in sync all the way through.
  6. Now add the new changes, save, commit and push, and merge to remote branch (not conflicts should be observed).
kajonas
  • 11
  • 2
0

In my case, I had uncommitted changes.

I committed my changes and then I was able to merge successfully without dirty_worktree error.

UsamaAmjad
  • 4,175
  • 3
  • 28
  • 35
0

So... another option that worked for me and my DIRTY_WORKTREE... Stash your changes and then Pull.

This solution meant that I did NOT lose some local useful logging changes from simply deleting the offending file.

RBrown
  • 193
  • 1
  • 1
  • 11
0

I had the same error as:

DIRTY_WORKTREE pom.xml

So I deleted the pom.xml from my working directory and did a pull from particular branch.

It worked for me.

Bulat
  • 720
  • 7
  • 15
Ajinkya Karode
  • 157
  • 1
  • 12
0

I resolved this error by selecting "Assume Unchanged" for the file that I was unable to delete.
STS, In the toolbar. Show View->Git Staging->Unstaged Changes.
OR
Right-click on the file->Team->Advanced->Assume Unchanged

Git Staging View

Shahan Mehbub
  • 69
  • 1
  • 4
0

The most simple and easy way is to Rebase

  1. Right click Repo > Rebase See image
  2. Stash your changes
  3. Done, WOW
  4. From the stashed changes just compare and take necessary code or you can apply stash
Shubh
  • 1
  • 2