3

I have some files in conflict, despite .gitignore should ignore them. If I try to update the solution I get Unmerged path.

git status brings the following:

On branch master
Your branch is up-to-date with 'origin/master'.

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add/rm <file>..." as appropriate to mark resolution)

    deleted by us:   abc_Library.userprefs
    deleted by us:   abc_Library/bin/Debug/abc_Library.dll
    deleted by us:   abc_Library/bin/Debug/abc_Library.dll.mdb
    deleted by us:   abc_Library/obj/Debug/abc_Library.dll

no changes added to commit (use "git add" and/or "git commit -a")

I already defined the following .gitignore

[Bb]in/
[Oo]bj/
*.userprefs
.DS_Store

As I can remember I already have fixed the untracked files. Can it be that a team member doesn't have the gitignore file and added the not needed files again? Or should I fix the untracked files again?

Edit:

Now I used

git rm --cached abc_Library/obj/Debug/abc_Library.dll

and the files don't appear as conflict anymore.

Community
  • 1
  • 1
testing
  • 19,681
  • 50
  • 236
  • 417
  • 3
    *Can it be that a team member doesn't have the `.gitignore` file* [...]? Is the `.gitignore` file itself under version control? – jub0bs Jan 15 '15 at 16:06
  • I only have added the file to my computer. How can I verify if it is under version control? – testing Jan 15 '15 at 16:39
  • 1
    Try running, for instance, `git ls-tree --name-only origin/master -- .gitignore`. – jub0bs Jan 15 '15 at 16:42
  • 2
    If a file is being tracked already, then putting it in `.gitignore` alone will have no effect. It will still be tracked, checked out, merged, etc. If you're attempting to use `.gitignore` to get around valid merge conflicts, then you're doing something quite ugly (dangerous, wrong, scary, ill-advised, ...). – twalberg Jan 15 '15 at 18:53
  • @Jubobs: When I run this command I get `.gitignore` as result. So it's being tracked? – testing Jan 16 '15 at 07:39
  • @twalberg: I know and therefore you can delete the index and add the files again like in the linked SO answer. I'm not using `.gitignore` to get around merging conflicts. The files can be regenerated all the time but they differ because of different plattforms. I don't need these files in GIT. I want to get rid of these tracked files. – testing Jan 16 '15 at 07:42
  • @testing Yes;it means it's being tracked. – jub0bs Jan 16 '15 at 08:14
  • @Jubobs: Removing the files as stated in my edited question seems to work. I hope it is now properly removed. – testing Jan 16 '15 at 08:16

1 Answers1

2

An excerpt from the documentation of .gitignore:

A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected.

When you add file names, paths or patterns to .gitignore you should remove the affected files from your repository:

git rm --cached abc_Library.userprefs

The option --cached asks git to remove the file only from the index, preparing this way the removal from repository on the next commit. The file from the working tree, modified or not, is not affected in any way.

axiac
  • 68,258
  • 9
  • 99
  • 134