Visual Studio 2013 was the first version to come pre-packaged with Git. When you create a new solution and elect Git as source control, it kindly places a new .gitignore file in your solution root folder. This tells Git to ignore a bunch of different files that you don’t want it tracking, including the bin and obj folders.
Any Visual Studio version prior to 2013 does not do this for you. So when I created a new solution in VS 2012 and used Git as source control manually through the command line, Git kept tracking all of the bin and obj folders. I ended up pushing a bunch of unnecessary files with every update. A trivial issue, but super annoying. Here’s how to fix it:
- Copy the .gitignore file from another solution that uses Visual Studio 2013 or higher, or copy the text from GitHub.
- Paste the file into your solution root folder, or, if you copied from GitHub, use the command line to create a new .gitignore file in your solution root and append the text to it.
- Finally, enter the following commands. This will reset your repo and tell Git to start ignoring the files in .gitignore.
git rm --cached -r . git add .