25

I'm running VS 2013 Update 3 with the 'Visual Studio Tools for Git' extension. This extension is for users of both team explorer and Git and I have no other Git and TFS related extensions installed and running. I use Microsoft's TFS Cloud service to backup and share my work.

Everything worked as expected for a few months. I want to be able to use this VS extension again, but the problem is that the files that should be ignored by .gitignore are being included by default. The same Git repository when viewed from the command line does not have this problem and works as expected.

Possibly important: I have at one time half-way set up a straight TFS account online but never used it locally and that never correlated with any problems I have mentioned here. Also, a long time ago I had to follow the advice in another posting to remove these binary files from version control because I added the .gitignore file too late. Since the command line doesn't have this problem I think something else is at work and that --hard reset actually worked as intended.

What is the problem with VS? Is there some way to change a setting or generally correct the oversight to ignore the files in the .gitignore file in the Git directory but not ignore the .gitignore file?

To head off some potential questions: I confirmed that the directories, and branches are the same on both interfaces by observing that all changes are added to Git/TFS and Posh Git as well as Git Bash and all other Git interfaces I have tried. The only problem is that additional files that should be ignored are not ignored in the VS extension.

Here is a sample of the .gitignore file that I use, which was produced by VS:

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

enter image description here

Eriawan Kusumawardhono
  • 4,796
  • 4
  • 46
  • 49
Justin Hale
  • 251
  • 3
  • 7
  • Can you show us your `.gitignore`? What is the path to the files that are not being ignored? When you say "not ignored" what exactly do you mean? Are files showing in the "included changes" list? – Edward Thomson Sep 04 '13 at 16:45
  • ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. # User-specific files *.suo *.user *.sln.docstates # Build results [Dd]ebug/ [Rr]elease/ x64/ build/ [Bb]in/ [Oo]bj/ – Justin Hale Sep 04 '13 at 16:50
  • @EdwardThomson The file is too big to show in its entirety. Above are some example lines. As you can see '[Bb]in/' is in the .gitignore file but the 'Included Changes' are all from a 'Bin/' directory. – Justin Hale Sep 04 '13 at 16:53
  • 1
    This sounds similar to a bug that exists in this version of the Git Provider. If you list the binary files explicitly (instead of the `bin/` directory) does it work? (This should be fixed in the next version, sorry!) – Edward Thomson Sep 04 '13 at 17:22
  • @EdwardThomson So I tried a few ways to specify what might be called a full path including D:\Full\Path\Bin\, Root\Git\Repo\Path\Bin\ & Root/Git/Repo/Path/Bin/ (with and without an asterick) thinking that an extension written for use on Windows might be fussy about such things as slash direction. None seemed to work when I pressed the refresh button on Team Explorer's changes pane. Thank you for letting me know the status. I may try to edit the exclude repository as per the octacat: https://help.github.com/articles/ignoring-files – Justin Hale Sep 04 '13 at 18:18
  • Did you find the solution or workaround? – Maximus Jan 11 '14 at 14:23
  • Now I see a different problem. Now if I open git from the command prompt or use GitHub for Windows I see a files that I do not see in Team Explorer. The difference is that Team Foundation now ignores line endings, apparently. I gather this because git status reveals "LF will be replaced by CRLF ... in your working directory." This is probably a windows only issue as I have read that a consistent policy for handling line endings was never quite perfected on Windows despite that fact that a variety of ways to deal with differences and make automatic changes are possible. – Justin Hale Jan 13 '14 at 12:49
  • @EdwardThomson I need to add a sort of disclaimer. I have, unfortunately, not done a systematic review of all the possible differences especially since I just discovered this one difference in the way lists of file difference are displayed. I have to note as well that although there are differences in the way git status and Team Foundation Explorer consider files changed, both ultimately ignored the potential conflict arising from line endings in the example given above. I.E. trying to use git add resulted in nothing to commit. The concerns may, therefore, be more aesthetic than anything else. – Justin Hale Jan 13 '14 at 13:05
  • Just an update, VS 2013 does the same thing. I thought for a moment that this was due to Git because the command line exhibited the same problem wherein the .gitignore file was not being used. This was only the case for old binary files that were already being tracked, however. New binary files like .dll files are tracked correctly in every Git version I have tried except the one used by VS. I even added another .gitignore file to my user directory to no avail. Perhaps VS uses a secret .gitignore file that nobody knows about? Either way it seems to be foobar. – Justin Hale Feb 14 '14 at 19:50
  • I found a link the problem elsewhere. The answer given doesn't work permanently but it provides a clue perhaps. Basically, VS adds an xml file to the .git folder and this helps VS make life difficult. http://social.msdn.microsoft.com/Forums/vstudio/en-US/ffc631e1-de5b-4fad-b173-b1f9318ef3fd/visual-studio-2013-and-gitignore?forum=visualstudiogeneral – Justin Hale Feb 14 '14 at 20:29
  • 1
    I'm seeing the same symptoms and am at a loss of explanation. I have a solution with 20 projects, 2 of them are Websites. I needed to include the *.refresh files, so I modified my gitignore file to comment out "[Bb]in/", and added "\*\*/[Bb]in/\*\*" and "!\*\*/[Bb]in/\*.refresh". Ever since I did that, the DLL files referenced by a .refresh file, and ONLY those files, are added to git when I build- DLL files in the other projects that are not website projects stay outside of source control, so I doubt it's a problem with .gitignore. Something is seriously wrong with VS's git implementation. – MisterZimbu Feb 19 '14 at 14:28
  • In addition, if I undo the changes instead of checking them in, I'm unable to change branches; it says I still have pending changes in the .DLLs I removed. Included/Excluded/Tracked files are all empty, and "git status" says there are no pending changes. – MisterZimbu Feb 19 '14 at 14:34
  • Anyone find a more permanent solution yet? @JustinHale link fixed the problem temporarily for me, but it randomly arises again with different files that should be ignored. Even after the latest update to VS. – trh178 Aug 14 '14 at 20:51
  • Unfortunately, Microsoft support staff emailed me a reply basically saying that this is a feature and not a bug. This will be an uphill battle. – haleonj Sep 15 '14 at 00:41
  • possible duplicate of [gitignore just doesn't work. I can't get it to ignore .DS\_Store & .gitignore files](http://stackoverflow.com/questions/21043132/gitignore-just-doesnt-work-i-cant-get-it-to-ignore-ds-store-gitignore-fil) – Paul Sweatte Nov 11 '14 at 23:08
  • Please be sure to update to VS 2013 Update 4, which has fixed a number of `.gitignore` bugs. – Edward Thomson Nov 23 '14 at 22:47

2 Answers2

13

We recently had the the same problem with the VS2013 git provider ignoring the .gitignore for only a few files. It turned out, there was ms-persist.xml in the .git folder with the two relevant sections <TrackedFiles> and <IgnoredFiles>.

As suggest in a blog post by Eric Nelson closing VS, deleting the file and restarting VS again solved the problem.

mbx
  • 6,292
  • 6
  • 58
  • 91
  • Eric's blog isn't accessible today, but this tip worked for me. Thanks! – DanM Jul 24 '15 at 13:08
  • 1
    @DanM Currently the site seems to be up, if it goes down forever eventually, there is still [the archived version on archive.org](https://web.archive.org/web/20140910055712/http://ericnelson.wordpress.com/2014/06/21/is-visual-studio-2013-ignoring-your-gitignore-file/) – mbx Jul 24 '15 at 15:33
1

You say that you are using VS 2013? If so, you do not need the extra git tools. I don't have them installed on my VS 2013, can use TFS with GIT just fine, and I don't experience the issue with .gitignore being ignored.

You can even manage the .gitignore via the IDE GUI so formatting should always be in the format desired by TFS/VS: http://msdn.microsoft.com/en-us/library/vstudio/hh967655.aspx#ignore

As stated in the Requirements from: https://visualstudiogallery.msdn.microsoft.com/abafc7d6-dcaa-40f4-8a5e-d6724bdb980c:

Note: Visual Studio 2013 includes Git tools by default so these tools are not needed. Learn more on MSDN: http://msdn.microsoft.com/en-us/library/vstudio/hh850437.aspx

j0ffe
  • 621
  • 8
  • 13