8

I'm using VS2015 GitHub extension, on a repositary I own (forked, really). Within the .gitignore file at some point I've this (taken from the fork, I didn't add myself that ignore):

...

VST3_SDK/*

...

but on VS2015 it seems to suggest a file within that folder has been "edited", and need to be staged:

enter image description here

I don't want this of course. These files/path should be "ignored" from versioning.

Where am I wrong?

EDIT: I don't want "workaround" to ignore it. I don't want to git it anymore...

markzzz
  • 47,390
  • 120
  • 299
  • 507

4 Answers4

8

It seems the file was committed once (maybe before it was ignored, maybe someone forced Git to start tracking it).

You can remove the file from Git (but not your harddrive) using

git rm --cached VST3_SDT/base/win/base_vc10.vcxproj.user

Afterwards, instead of "modified" the file will appear as "deleted". This is expected and should be committed (this commit will fix the issue for all other developers on this project, too). Afterwards Git will ignore the file for you and everybody else.

Nils Werner
  • 34,832
  • 7
  • 76
  • 98
6

.gitignore works for files that are not part of the project yet. If a file is already part of the project (it is part of HEAD already) then .the file being part of .gitignore does not matter. If this file is already part of the project and you still don't want to see it as modified (weird, but possible) then you have to use git update-index to tell git to just not care about it.

eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • Thinking about it, I'm wondering if libgit2 (the library used by VS's implementation of git, right?) actually resembles native git's behavior (which is what I described on my comment). – eftshift0 Mar 15 '17 at 14:53
  • So what should I do? – markzzz Mar 17 '17 at 14:25
  • 1
    If the file is already _in_ the project but you actually don't care if the file changes, then ask git to not care about it: git update-index --assume-unchanged blah/blah/blah.txt That should be enough. https://git-scm.com/docs/git-update-index – eftshift0 Mar 17 '17 at 14:47
  • Uhm, that's a workaround! I don't want to "ignore it", but remove it from gitting... – markzzz Mar 21 '17 at 09:42
  • Well... you could then ```git rm --cache``` it so that it goes away from git (while still keeping it on your working tree.... and if it's in git ignore git won't tell you anything about it after you commit it)... or you could go back in history and rewrite the history so that the file is not on any previous commit. – eftshift0 Mar 21 '17 at 14:58
0

You ignore directories and everything inside/below them like this:

VST3_SDK/

Do not use * at the end.

kriegaex
  • 63,017
  • 15
  • 111
  • 202
-1

There is a bug in VS2015 (and VS2013) which causes some .gitignore rules to not be adhered to.

Solution 1:

Try searching for the file .git\ms-persist.xml within your solution directory and deleting it (you may have to ensure you can see hidden files and folders). Once you restart Visual Studio, it will re-read your .gitignore (regenerating ms-persist.xml) and should stop tracking the ignored file(s).

Solution 2 Workaround:

If this doesn't solve your problem, the next step would be to explicitly declare the file you don't want tracked in your .gitignore:

...
VST3_SDK/*
VST3_SDK/base/win/base_vc10.vcxproj.user
...
codemacabre
  • 1,112
  • 12
  • 20