169
votes

This question has nothing to do with git itself; rather, it has to do with removing a binding/mapping to a git repository that Visual Studio 2015 (VS2015) has previously seen.

Here's a screen shot of the problem: Remove button is grayed out

Notice that the remove button is grayed out (disabled). How can I remove this entry from the "Local Git Repositories" list?

17
It's easy with currently unpublished NoGit release, see stackoverflow.com/a/33789257/2284031Ben Wilde
When adding new solution note that the "add to git Repository" is not checked on small bottom rightIman
None of the answers below work for me. So I just used a workaround: close Studio, rename .git folder to any name e.g. .git1, open Studio, rename git folder back to .git. Remember that in order to give a folder name starting with a dot in Windows, you need to add an extra dot at the end of the name i.e. ".git1."bruha

17 Answers

224
votes

The solution is much simpler than that. You simply need to remove three files from the project UNC Path.

Navigate to your solution's UNC Path.

Example: C:\Users\Your User Name\Documents\Visual Studio 2015\Projects\Your Project Folder

Then permanently delete ("SHIFT + DEL") the .git* files and folder. There are two files and one folder, which may be hidden so ensure you have your folders and search options > View > show hidden files, folder, and drives (Radio Button) Selected.

The files to permanently delete are:

.gitignore (file)

.gitattributes (file)

.git (folder)

Reopen Visual Studio and there is no more relationship to the Git Source Control. If you wanted to take it as far as removing it from the registry as mentioned above, you could, but that shouldn't be necessary aside from the "house keeping" of your machine.

63
votes

Tools -> Options -> Source Control -> Current Source Control Plug-in: None

42
votes

Short Version

  1. Remove the appropriate entr(y|ies) under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\Repositories.

  2. Remove HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\General\LastUsedRepository if it's the same as the repo you are trying to remove.

Background

It seems like Visual Studio tracks all of the git repositories that it has seen. Even if you close the project that was referencing a repository, old entries may still appear in the list.

This problem is not new to Visual Studio:

VS2013 - How do I remove local git repository from team explorer window when option Remove is always disabled?

Remove Git binding from Visual Studio 2013 solution?

This all seems like a lot of work for something that should probably be a built-in feature. The above "solutions" mention making modifications to the .git file etc.; I don't like the idea of having to change things outside of Visual Studio to affect things inside Visual Studio. Although my solution needs to make a few registry edits (and is external to VS), at least these only affect VS. Here is the work-around (read: hack):

Detailed Instructions

Be sure to have Visual Studio 2015 closed before following these steps.

1. Open regedit.exe and navigate to

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\Repositories

Regedit repositories for VS

You might see multiple "hash" values that represent the repositories that VS is tracking.

2. Find the git repository you want to remove from the list. Look at the name and path values to verify the correct repository to delete:

verify repo to delete

3. Delete the key (and corresponding subkeys).

(Optional: before deleting, you can right click and choose Export to back up this key in case you make a mistake.) Now, right click on the key (in my case this is AE76C67B6CD2C04395248BFF8EBF96C7AFA15AA9 and select Delete).

4. Check that the LastUsedRepository key points to "something else."

If the repository mapping you are trying to remove in the above steps is stored in LastUsedRepository, then you'll need to remove this key, also. First navigate to:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\General

location of general key

and delete the key LastUsedRepository (the key will be re-created by VS if needed). If you are worried about removing the key, you can just modify the value and set it to an empty string:

delete last used repo

When you open Visual Studio 2015 again, the git repository binding should not appear in the list anymore.

23
votes

A Git repository can be removed from the Local Git Repositories list in VS-2015 when it is no longer the active project.

Your screen shot has only have one repository present, and it is active, so you can't remove it.

When you have two or more repositories, one of them will be shown in BOLD representing the active repository. Other non-active repositories can, at that time, be removed.

So, to solve your problem, if you connect with a second local repository, you will be able to remove the one you are highlighting in your screen shot.

Unfortunately, Team Explorer seems to always keep one repository active. Not sure how to convince it to let go altogether without switching to another repository.

19
votes

Removing .git hidden folder worked for me.

15
votes
  1. Navigate to your project directory
  2. Click on the folder Menu-> Tools-> Folder options
  3. Select the View-tab
  4. Select Under File and Folders the Show hidden files, folder, and drives
  5. Click OK
  6. Delete the .git folder
  7. Close and re-open you Visual Studio
  8. Open your project
  9. Done. :)

Safe coding.

12
votes

The above answer did not work for me. The registry entries would just be automatically re-added when I opened the solution in Visual Studio. I found the resolution in one of the links in Matthews answer though so credit still goes to him for the correct answer.

Remove Git binding from Visual Studio 2013 solution?

Remove the hidden .git folder in your solutionfolder.

I also removed the .gitattributes and .gitignore files just to keep my folder clean.

9
votes

NoGit extension simply hides the problem, by turning off the Git source control provider each time the solution is loaded. It does this job for every solution that is loaded in Visual Studio.

I solved by opening another project and removing the Git repository from the Local Git Repositories, as Chris C. suggested (View > Team Explorer > Local Git Repositories, select the repository that has to be removed and click Remove). Then I removed .git folder from the project path, as suggested by helix. Reopened the project and finally Git integration was gone!

7
votes

It's so simple,

  1. make sure that you are not connected to the project you want to delete

  2. project is closed in the solution explorer

    That'a all, if your retry now, the remove action will enabled

5
votes

I spent some time to remove the git integration from my visual studio 2015 project. any time i remove git from visual studio, and add TFS by following this -- Tools -> option -> sourceControl -> plugin selection -> Visual Studio Team foundation server, it used to come back.

My solution was -

making the physical location of my project- Show all hidden files. you can do this by show hidden files and folder option of windows. then i realize, there was a hidden folder called .git something. I kept a full back up of my project folder and also the git folder any other back up that necessary (I kept this back up incase my project breaks, so that i can go back to previous condition).

then i have deleted the hidden .git folder and any other .git related files.

then i try to Tools -> option -> sourceControl -> plugin selection -> Visual Studio Team foundation server. then i open the project by visual studio- File -> open -> project/solution..

after that i noiticed in solution explorer , right clicking the solution namei see "Source control" option , and also in project - right click i see "Add soution to source control".. and this time it didn't add solution to git..

also it is good to remove any git connection from your source control exploerer..if there is any..

so the main thing is that make sure there is no hidden git file in your project file and any other git extension.. hope this will be helpful to someone..

2
votes

@Matthew Kraus Please Click tools from menu bar then click Options , Find the Source Control then select "None" from dropdown list and Click OK. Delete hidden .git folder from your project folder. Re-open your project. enter image description here

2
votes

In addition to Juliano Nunes Silva Oliveira's answer, the simplest and most clean way without hacking into the regedit, removing hidden .git folders or changing your VS15 settings is by connecting to a different repository. When connected you see the text of the other repository bold then select your Git local repository. Now you see that the

Remove

menu item is enabled so you are able to delete your Git local repository.

It's the same type of behaviour when dealing with Branches when using Git with visual studio 2015. You need to select different branch before you can delete the branch you wan to delete.

For the ones who needs visualization to understand it better. see link image: how it's done

Happy coding

1
votes

It just looks for the presence of the .git directory in the solution folder. Delete that folder, possibly hidden, and Visual Studio will no longer consider it a git project.

1
votes

Connect to a different repository (I tried with a TFS repository), then go to Manage Connections, right click the Git repository and you might be able to remove it.

But you still have to manually remove the .git folder and files from your project path before opening the solution again.

0
votes

Go to Control Panel\User Accounts\Credential Manager and select Windows Credential then remove account of git.

0
votes

download the extension from microsoft and install to remove GIT extension from Visual studio and SSMS.

https://marketplace.visualstudio.com/items?itemName=MarkRendle.NoGit

SSMS: Edit the ssms.pkgundef file found at C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\ssms.pkgundef and remove all git related entries

0
votes

You cant delete local git repository when its already connected. so close the solution, open another solution and then remove the local git repository. dont forget to delete .git hidden folder works for me