Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Files to ignore when using Visual Studio with Git

I've installed Git to do some development using Visual Studio 2008. Most of the work will be new development but we do have some old projects from prior to VS2005 that I want to bring over into the new repository. There is an existing thread about general VS/Git integration but my question is limited to the .gitignore file and Visual Studio.

My question has two parts:

  • What entries should be included in the .gitignore file to cover the Visual Studio specific files like binaries, assemblies, debug files, etc? Some were covered in the thread mentioned above but is there a comprehensive set?

  • In what situations have you needed to exclude files globally, or for a single repository, or using the environment variable?

I already know the HOW. Here is an excerpt from the Git user-manual on ignoring files.

If you wish the exclude patterns to affect only certain repositories (instead of every repository for a given project), you may instead put them in a file in your repository named .git/info/exclude, or in any file specified by the core.excludesfile configuration variable. Some git commands can also take exclude patterns directly on the command line. See gitignore(5) for the details.

like image 587
Kelly S. French Avatar asked Nov 04 '09 22:11

Kelly S. French


People also ask

What files should I Git ignore?

gitignore should contain all files that you want to ignore. Therefore, you should ignore files generated by the OS, the IDE you are working on... My question appears when the repository is on Github and people can clone it and push the changes. These people can use other operating systems and can use other IDEs.

How do I ignore some files while committing in Git from Visual Studio?

In Visual Studio, you can directly Click on "Git" -> "Settings" -> Then select "Git Repository settings" -> then in section "Git Files", click the Add button for Ignore file.

How do I ignore changes in Visual Studio Git?

Visual Studio Git In the Git Changes window, right-click any changed file that you want Git to ignore and choose Ignore this local item or Ignore this extension. Those menu options don't exist for tracked files.

What is Gitignore Visual Studio?

01/04/2022 by Mak. It's important to add . gitignore to your git repository. This tells git which files in your source directory to not track.


2 Answers

Just found this - https://github.com/github/gitignore

Specifically this - https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

like image 69
bluekeys Avatar answered Sep 21 '22 02:09

bluekeys


In GitExtensions the default .gitignore is this. It can be a bit shorted by removing most individual file extensions and only exclude the directories they are in.

*.obj
*.exe
*.exp
*.pdb
*.dll
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.zip
[Dd]ebug*/
*.lib
*.sbr
Thumbs.db
[Ll]ib/
[Rr]elease*/
[Tt]est[Rr]esults/
_UpgradeReport_Files/
_ReSharper.*/
like image 24
user195595 Avatar answered Sep 20 '22 02:09

user195595