1

I try to merge my git repository with a remote one and what i get is this:

Merge Result: Failed Merge of HEAD with remote-rep/master failed because of these files: /path/to/some/file.jpg

The whole folder that file is in is shown as ignored by git. I checked it in .gitignore and it is there. Those files have never been added on commit also.

2
  • Does the file show up when you run git ls-files?
    – vergenzt
    Commented Jun 26, 2012 at 12:48
  • 1
    Also try git ls-tree --name-only remote-rep/master and see if /path/to/some/file.jpg is tracked on the remote branch. If so, it makes sense that the merge fails even though you don't track it.
    – vergenzt
    Commented Jun 26, 2012 at 12:52

2 Answers 2

2

The file could have been added by others in the remote repo. If you really think the file must be ignored, then do this.

  1. Move the file (local) to some other location.
  2. Merge the remote repo with your master.
  3. Untrack the file. git rm /path/to/some/file.jpg
  4. Commit and Push.
  5. Move back your local file to the previous location.
  6. Inform your colleagues about this change. ;-)

The best way to avoid this issue is by committing .gitignore file. So that everyone shares same .gitignore file.

2
  • I think that doing a git rm --cached /path/to/some/file.jpg is easier than that. Commented Jun 26, 2012 at 13:25
  • 1
    @YuriAlbuquerque: I agree. In case they both are same file (I mean content). git rm --cached /path/to/some/file.jpg would be enough. Commented Jun 26, 2012 at 13:31
0

Please try git command in shell instead of the options in Netbeans. You will see the difference!

Not the answer you're looking for? Browse other questions tagged or ask your own question.