Visual Studio Git Ignore Instructions
This document is meant to help with the use of the Visual Studio gitignore template that tells the Git version control software to ignore files that are generated by Visual Studio during the build process.
All instructions in this document use the Visual Studio gitignore template located at this link.
The instructions are broken down into two main categories:
And some additional considerations in “Additional Considerations”.
Starting with a fresh repository
Using the Visual Studio gitignore template is extremely easy if you are starting with a new repository. Simply open the .gitignore
file at the root of the repository and copy/paste the contents of the .gitignore
template found here.
Starting with an existing repository
Starting with an existing repository that contains a Visual Studio project isn’t as straightforward as starting with a fresh repository. This is because it is very likely that some of the files that the gitignore template indicates for Git to ignore are likely already committed and part of the repository’s history. However, the whole process can be completed in around 5 minutes and will significantly cut down the rate at which the repository’s size grows.
The instructions are as follows:
- Follow the instructions to copy/paste the Visual Studio
.gitignore
template found under “Starting with a Fresh Repository” into the repository’s.gitignore
file. - Delete the previously committed files that should be ignored. For ease, the most common directories that need to be deleted are listed below:
- The
$PROJECT_ROOT$\.vs\
directory. - The
Release
directory. This can be found in multiple places depending on what CPU architecture you’re building the project for, but in FiberSim this is found underC++/FiberSim/x64/Release/
.
- The
- Make a new commit that adds the deletion of all of these files to Git and then push the changes.
Additional Considerations
If the repository that you are working with also uses Python, I would recommend following the same methodology under “Starting with an Existing Repository except with the Python .gitignore
template found at this link. The most common files that need to be deleted with Python are the python byte code (.pyc
) files. Simply update the .gitignore
file in the repository, delete the .pyc
files, make a commit, then push the changes.