180

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?

Matthew Kraus
  • 6,660
  • 5
  • 24
  • 31
  • It's easy with currently unpublished NoGit release, see http://stackoverflow.com/a/33789257/2284031 – Ben Wilde Nov 18 '15 at 20:01
  • When adding new solution note that the "add to git Repository" is not checked on small bottom right – Iman Aug 22 '16 at 03:57
  • 1
    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 Feb 08 '18 at 14:57

17 Answers17

233

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.

Community
  • 1
  • 1
helix
  • 2,467
  • 1
  • 9
  • 2
  • 2
    +1. In my experience, playing with the registry doesn't seem to work too well. I did this after copying my project to another location (a vm to a local) and after removing the .gitignore, .gitattributes and .git, this did the trick. – cr1pto Apr 26 '16 at 21:35
  • 45
    -1 This isn't removing the git mapping in VS, it is removing the git repository itself. The reason VS stops being mapped to git with these steps is you've blown away the repo. What about people that want to use git, but don't want VS getting involved? This is what the OP was asking. – Rob Levine May 04 '16 at 10:05
  • Ah, so @RobLevine, destroying the repo and remapping it/readding it isn't what should be done after all? Why is not destroying the repo a good idea (aside from what you've said already - is that the only reason)? Your answer will help me a lot since I'm still actually very new to git and don't completely understand...I messed with the registry and actually destroyed my VS installation and didn't want to risk doing that again, just so you can understand my concern. I did helix's answer and this fixed the problem - I just had to re-add to git and problem solved... – cr1pto May 04 '16 at 16:42
  • 5
    @Richard_D - basically - if you are using git in the standard way, then this .git folder *is* git. It is both your local copy of everything that is on your upstream git server and is also probably the only copy of any local branches you've created but not pushed. Lots of people use git from the command line, or tools like SourceTree and don't want to use the git integration in VS. In this case, all we want is to disable git support in VS, not actually tamper with our local git installation. Does that make more sense, or have I misunderstood your concern? – Rob Levine May 04 '16 at 16:57
  • The registry edits didn't help me, but removing those 2 files and 1 folder did. – BitsAndBytes Jun 25 '16 at 14:09
  • Thanks Helix, very simple. Glad MS didn't opt to embed it somewhere in a solution file. – William T. Mallard Jun 16 '17 at 17:30
  • 4
    This is a *horrendous* idea. Criminally negligent comes to mind too. Seatbelt defeaters is another one. This isn't removing any mapping, it's deleting the repository itself. – Panagiotis Kanavos Sep 01 '17 at 07:48
  • 3
    In my case it worked perfectly. By mistake I had trired to add a project to source control and it some how put it in a GIT repository locally. This defats the purpose of source control because if the drive crashes I lose everything. I tried to connect to TFS and it kept defaulting back to GIT. By removing all the GIT files, and reopening VS, it worked perfectly for me. +! kind sir! – logixologist Apr 06 '18 at 15:45
  • Why shift del? What the heck is that suggestion? Why not just move elsewhere or rename for a moment. There might be something valuable! ... Thus, this is a simply a workaround ... and not a right one for sure. – Artfaith Feb 11 '20 at 17:16
  • If you want to keep using the Git repo but not from inside Visual Studio, I have found a reasonable solution that works even for VS2019: https://stackoverflow.com/a/61658739/306074 – Anlo May 07 '20 at 13:23
71

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

Laurent
  • 478
  • 7
  • 15
Jean Noel
  • 947
  • 9
  • 7
42

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.

Community
  • 1
  • 1
Matthew Kraus
  • 6,660
  • 5
  • 24
  • 31
  • I don't think playing with the registry is a good idea...if this has worked for some, cool, but in my experience this isn't the safest bet. See @helix's answer for a much safer solution. – cr1pto Apr 26 '16 at 21:36
  • 4
    @Richard_D - helix's answer does not remove the VS mapping to git, it destroys the git repo itself, which is not what the OP seems to be asking. Hacking the registry isn't ideal, but at least it attempts to solve the actual problem "I am using a git repo but don't want VS to get involved" – Rob Levine May 04 '16 at 10:07
  • I see that this answers the OP's question, but is this the correct answer? I am not sure. Please see my questions in @Helix's answer. Thanks Rob, appreciate your insight. – cr1pto May 04 '16 at 16:45
  • 2
    VS2015 just restores these registry entries the next time the solution is opened. – Amit G May 12 '16 at 09:27
  • 2
    Developers shouldn't be afraid editing Windows Registry. Especially when it's obviously a Visual Studio key! Deleting the .git directory is not an option for me. – 0xF Sep 01 '16 at 07:47
23

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.

Chris C.
  • 959
  • 1
  • 8
  • 17
  • But how do you "Connect" to the other repositories? It seems like once VS is on a repo it does not allow you to connect to another using the same "Add to Sorce Control" option in the solution explorer menu. (nvm deleting the .git and other git files from the solution dir worked for me.) – Gram Dec 14 '15 at 18:09
  • @Gram. Under Local Git Repositories (see OP screen shot) you can create a 'New' Git repository or 'Clone' an existing one. If you create a New git repository, give it a path on your local hard drive, then click Create. After that, it will appear in your list. Double-click on the new repository and it will be highlighted in bold text and behind the scenes become the active repository. At that point you can remove other repositories from the list. – Chris C. Dec 15 '15 at 07:16
  • That is making a new local repo, not connecting an existing project to an existing github repo. Oops, on a second read over I see removing is the only question. How to connect to existing is not a part of the question, my mistake. – Gram Dec 15 '15 at 15:14
22
  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.

Anbuselvan Rocky
  • 606
  • 6
  • 22
Rodney Godfried
  • 219
  • 2
  • 4
  • 1
    That is NOT what we are trying to do. We want git, we just don't want VS integration with git. – Gerry Jun 11 '19 at 16:32
21

Removing .git hidden folder worked for me.

sensei
  • 7,044
  • 10
  • 57
  • 125
  • This will transform the folder from a git checkout into a folder. Sure one should not alter the purpose of a checkout directory because Visual Studio does this or that. – Cristian Amarie Jun 08 '18 at 10:29
  • Super late, but thank you so much... This had to be one of the most frustrating and annoying mornings of my entire career thus far, what a stupid functionality they have built into handle this... – haag1 Mar 29 '19 at 13:47
14

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.

Community
  • 1
  • 1
Gene S
  • 2,735
  • 3
  • 25
  • 35
  • 2
    This isn't any use if you want the project to be managed by git, just not via Team Explorer. I find personally that Team Explorer messes with my use of Git via a different VS plugin, which is entirely undesirable. – Henry Wilson Dec 16 '15 at 12:31
  • This does not remove the git add-in from VS. VS continues to beat the Git bush and it is aggravating. – IAbstract Apr 07 '16 at 17:43
  • @IAbstract The question does not ask to remove the git add-in from VS. – Gene S Jun 10 '16 at 14:46
  • @Henry Wilson It doesn't seem like you comment is relevant to the question. My answer does remove the binding/mapping from Visual Studio. It works for me and clearly works for others. – Gene S Jun 10 '16 at 14:49
  • 1
    It's entirely relevant to the question! The OP doesn't state whether he's using git for source control or not, he merely wants to know how to get rid of the binding in VS. Deleting the .git folder and .gitattributes / .gitignore files assumes you're not actually using git for source control, which many people might well be. – Henry Wilson Jun 13 '16 at 09:58
  • I need to move project from Git to TFS. I've tried to remove .git* folders, changed Tools\Options\Source control to TFS but next time with Add to source control option VS creates .git repository again. So I've removed .git folders, deleted registry key and was able to add to TFS with File\Source control\Add menu – oleksa Jun 26 '17 at 11:46
9

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!

jeanie77
  • 515
  • 1
  • 4
  • 22
  • Just removing the .git folder and a couple .git files from the Solutions's folder fixed it for me. Thanks all! – PTansey Jul 19 '16 at 21:21
7

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

Community
  • 1
  • 1
erradi mourad
  • 259
  • 4
  • 7
5

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..

Roman Pokrovskij
  • 9,449
  • 21
  • 87
  • 142
Aman
  • 47
  • 1
  • 4
3

@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

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

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.

M Ahmad
  • 21
  • 2
  • That's because if you remove it *it is no longer a git project*. You have effectively destroyed your versioning. If that's what you want to do, fine. – gliljas Jul 14 '16 at 14:27
  • That's exactly what I wanted to do. Visual Studio decided to expire my 30-day license as I was adding it to source control. Left my project in a state that was confusing and I couldn't follow the documentation on. – Nathan Goings Jan 17 '17 at 03:37
1

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.

juliano.net
  • 7,982
  • 13
  • 70
  • 164
0

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

0

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

Ramkumar Sambandam
  • 487
  • 1
  • 6
  • 11
0

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

netanel elipaz
  • 121
  • 1
  • 5