locked
Visual Studio 2013 and .gitignore RRS feed

  • Question

  • It seems that the Visual Studio 2013 git functionality will not abide by the .gitignore file in the repository.  It will not ignore files with .cpp or .h extensions.  This is a problem because we are using native nuget packages which put files with these extensions inside the /packages/ directory inside the solution directory.  Visual Studio sees these and wants to add them in the next commit unless I go in and manually exclude them.  This is despite the fact that I have a line in my .gitignore that is

    packages/

    I also tried adding

    packages/**/*.cpp
    packages/**/*.h

    To see if I could force it, still no luck.  The command line git tools behave just fine.  Also visual studio correctly ignores other files in packages, it is just the C++ files that it won't give up.

    Does anyone know why visual studio is doing this?  And how I can make it stop.  I am concerned because eventually some of our developers are going to forget to check the included files list when doing a commit with visual studio, and we will get a bunch of package contents commited to our repositories.

    Sunday, October 27, 2013 9:43 PM

Answers

  • We are using the standard nuget 2.7 that ships with vs2013.  We use it to install libraries into our C++ projects.  Anyway, it turned out the the issue can be resolved by shutting down visual studio, and then deleting the ms-persist.xml file from the .git folder, and then restarting visual studio.  After that, it seemed to honor the .gitignore file, and stopped trying to add files from the /packages folder into the git repository.  I'm guessing that the problem might have been caused the the older git extension for Visual Studio 2012, but stayed around because it was baked into that ms-persist file.

    Friday, November 1, 2013 2:27 PM

All replies

  • Hi Chris,

    Thank you for posting in the MSDN forum.

    Sorry for that if I misunderstand this issue.

    This is a problem because we are using native nuget packages which put files with these extensions inside the /packages/ directory inside the solution directory.

    Do you mean that you install an extension tool in your VS IDE? Where did you get this extension tool? If this issue is related to the specific extension tool “NuGet Package Manager for Visual Studio 2013”, like the information from the above link:

    If you have any problems installing NuGet, please refer to our list of known issues.

    I suggest you post this issue to NuGet forum for better support.

    Since you said that Git repository, whether this issue is related to the Application Lifecycle Management with Visual Studio Team Foundation Server like the following MSDN document?

    http://msdn.microsoft.com/en-us/library/vstudio/hh967655.aspx#ignore

    Since this forum is to discuss the Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor. So we need to make sure that whether it is the VS General issue. If it is, if would be better you could share me the detailed steps to repro this issue, please also share us the detailed tools we would have in my side. Thanks for your understanding.

    But if this issue is also related to any extension tools, I suggest you post this issue to the specific extension tools forum or where you download them.

    If I have misunderstood anything, please make free feel to let me know.

    Sincerely,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, October 29, 2013 6:07 AM
  • Hi Chris,

    I am writing to check the status of the issue on your side. 

    Would you mind letting us know the result of the suggestion?

    Have a nice weekend,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 1, 2013 1:52 AM
  • We are using the standard nuget 2.7 that ships with vs2013.  We use it to install libraries into our C++ projects.  Anyway, it turned out the the issue can be resolved by shutting down visual studio, and then deleting the ms-persist.xml file from the .git folder, and then restarting visual studio.  After that, it seemed to honor the .gitignore file, and stopped trying to add files from the /packages folder into the git repository.  I'm guessing that the problem might have been caused the the older git extension for Visual Studio 2012, but stayed around because it was baked into that ms-persist file.

    Friday, November 1, 2013 2:27 PM
  • I had a different issue: trying to keep generated intermediate service reference files (xsd, disco, svcinfo) out of the repository. I had this working fine in Git but VS 2013 was ignoring the .gitignore file. Deleting ms-persist.xml solved the problem, thanks!
    Monday, March 17, 2014 5:39 PM
  • Thanks! I removed that file and VS quit ignoring my .gitignore entries.

    -- Ralph

    Wednesday, April 16, 2014 9:03 PM
  • I don't think that deleting the ms-persist file is a reasonable workaround for this issue. If I newly clone a repository with Visual Studio 2013 Update 2, create a new solution, add a NuGet package adds some file links to the project where the file is stored in the packages folder, Visual Studio want's to add the files to source control, even if packages folder is in .gitignore.

    Of course after deleting ms-persist.xml it works, but I don't see this as a solution, because in the end this is not much of a difference than excluding these files in the Visual Studio GUI and requires still manual steps from each developer.

    Friday, May 16, 2014 9:31 AM
  • I have the same issue w/out any NuGet packages being involved.

    Plain ol' .gitignore is being ignored. I added a filter to the file (*.dushan). When I check the git repo manually (using Git Bash), that file is (correctly) ignored. But in VS, it's there, and yes it does get committed. If I commit from GitBash, it (correctly) gets ignored.

    This shouldn't be... is this a bug? There really shouldn't be a workaround for something so fundamental to git.

    Dushan

    Wednesday, June 4, 2014 5:10 PM