Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DIRTY_INDEX at merge

Tags:

git

git-merge

I fetched some updates from upstream, merged, and got the following error message:

FAILED: DIRTY_INDEX [filename]

After a reset and another merge, I get this error:

FAILED: DIRTY_WORKTREE [another-filename]

All this is cryptic to me - what should I do now?

like image 759
Erel Segal-Halevi Avatar asked Jun 02 '13 07:06

Erel Segal-Halevi


People also ask

What is dirty index?

The index is the place in git where you register the changes you want to include in your next commit (via git add ). If you have no changes recorded on your index at all, the index is considered clean, but if there are files added to the index, the index is considered dirty.

What is dirty Worktree?

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.

How do you fix a dirty work tree?

To resolve this issue you can do the following. Always commit your local changes in the file or stash them before you apply the pull/merge operation on the local branch. if you have forgotten step 1, and already facing DIRTY_WORKTREE then either you have to stash your uncommitted changes and then pull.


2 Answers

I also had the same problem. My suggestions for the solution would be: 1. Before checking out the project from origin, make sure in the Project tab, the Build Automatically option is turn off. And try merge with the other branch.

like image 69
BruceWayne Avatar answered Nov 05 '22 05:11

BruceWayne


As mention ed in "Fun with keeping local changes around":

Linus often performs patch applications and merges in a dirty work tree with a clean index.

  • A dirty work tree is where you have changes that are not added to the index.
    A work tree that is not dirty is a clean work tree.
  • A dirty index is where you have changes already added to it (in other words, "git diff --cached" will report some changes).
    A clean index matches the HEAD.

Each time, git status can display what you need to do before being able to do a new merge.

git stash, for instance, can save current work in progress in your working tree, and git stash pop will apply said work once the merge is done.

like image 21
VonC Avatar answered Nov 05 '22 05:11

VonC