banner



How To Add Gitignore File In Visual Studio

A few years ago I wrote a post roofing how to Add Git Ignore to an existing Visual Studio Project which was using Visual Studio 2015 I believe. Though information technology is an old mail, it holds up through the current version of Visual Studio. Fast forward to today and Visual Studio has a new Git Experience in preview which alters this procedure. This post volition cover adding a Git ignore file to an existing solution using Visual Studio'southward new Git experience. If you don't see the Git carte in Visual Studio run into the previous link for information on enabling the feature preview.

Using Visual Studio to add a .gitignore

Open up Visual Studio and the solution needing an ignore file. From the top menu select Git > Settings.

The above will open up Visual Studio's Options with Source Control > Git Global Settings selected. From the list on the left select Git Repository Settings then click the Add button for Ignore file.

The higher up will add a .gitignore file with all the proper files ignored for a typical Visual Studio setup. Switch to the Git Changes window and enter a commit message and then click the Commit Staged button to commit the change to your current working co-operative.

Terminate tracking files that should be ignored

To finish tracking the files in the ignore file open up a control prompt and navigate to the directory that contains your solution file (.sln) and run the following commands.

git rm -r --cached .  git add . git commit -am "Remove ignored files"

The Git commands above were pulled from here. There are other answers in that thread if the above doesn't piece of work on your project for some reason.

Wrapping Up

It is always simpler if you lot tin can start a project with a Git ignore file in place, but if for whatever reason that couldn't happen hopefully this post will get you going. If you aren't using the new Visual Studio Git experience then the original version of this post will be more than helpful. Bank check out the Microsoft post for more details on the new Git experience.

How To Add Gitignore File In Visual Studio,

Source: https://elanderson.net/2020/10/add-git-ignore-to-an-existing-visual-studio-solution-new-git-experience/

Posted by: callahanutmacksmay.blogspot.com

0 Response to "How To Add Gitignore File In Visual Studio"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel