1

I am getting this error when I try to merge master and developer git branch from Zend Studio UI. When I try to do this by command line I get this error:

error: your local changes to the following files would be overwritten by merge

even that the list of files have not been changed. After I tried this How to ignore error on git pull about my local changes would be overwritten by merge? but on the next try of merge I get conflicting in all files.

How can I solve this mess?

Community
  • 1
  • 1
albanx
  • 6,193
  • 9
  • 67
  • 97

3 Answers3

0

You have modified some files and haven't commit them to your repo. Check your status with

git status

and add all open changes to your branch. If you have uncommitted changes and you try to merge that error occurs. You can work with git stash and git pop either.

René Höhle
  • 26,716
  • 22
  • 73
  • 82
  • But I do not have uncommited changes. With git status I see a list of files in red "Changes not staged for commit". – albanx Apr 11 '15 at 20:53
  • running a git checkout the files seems to be reseted but on git status they appear again – albanx Apr 11 '15 at 20:57
  • You should really read a git tutorial first ;) https://www.atlassian.com/git/tutorials/saving-changes/git-add – René Höhle Apr 11 '15 at 21:01
  • I have not change that files, believe me, I do not need a git tutorial, it is been a lot of time I am using git. I have the master branch and the developer branch. I am trying to merge master into developer since I have made some hot fix to master.. I think that the problem could be the fact I have replaced some folders manually (maybe some git system file have corrupted informations) – albanx Apr 11 '15 at 21:05
  • Have you enabled your crlf? Then git change all line endings and you have automatically modified files. – René Höhle Apr 11 '15 at 21:08
  • I fixed the branches by fixing one by one the files. Now I edit a file in master,commit and pushed it, then I switch in developer, trying merge I got a conflict in that file... I am going to delete branches to make a clean branch – albanx Apr 11 '15 at 21:49
  • OK by deleting and then re-creating (from developer) the master branch all seems to be fine now. I believe that the problem was Zend Studio command : Replace With-> Branch when replacing the entire project (as I did by replacing master with developer). – albanx Apr 11 '15 at 22:02
0

In my case, the DIRTY_WORKTREE was caused by this sequence:

  1. In a commit, I committed also some files that I should have ignored
  2. In the next commit I modified the .gitignore that ignore the above files
  3. Try to rebase on top of another branch where my change to .gitignore is missing

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 (works for any Eclipse based IDE like Zend Studio) I did the following:

  • 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.
psuzzi
  • 2,187
  • 1
  • 17
  • 21
0

In my case, I had uncommitted changes.

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

UsamaAmjad
  • 4,175
  • 3
  • 28
  • 35