删除 Visual Studio 2015 中的 git 映射

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32304977/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:32:33  来源:igfitidea点击:

Remove git mapping in Visual Studio 2015

gitvisual-studio-2015team-explorer

提问by Matthew Kraus

This question has nothingto 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.

这个问题与git本身无关;相反,它与删除 Visual Studio 2015 (VS2015) 之前看到的 git 存储库的绑定/映射有关。

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?

请注意,删除按钮变灰(禁用)。如何从“本地 Git 存储库”列表中删除此条目?

回答by helix

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

解决方案比这简单得多。您只需要从项目 UNC 路径中删除三个文件。

Navigate to your solution's UNC Path.

导航到您的解决方案的 UNC 路径。

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

示例: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.

然后永久删除(“SHIFT + DEL”).git*文件和文件夹。有两个文件和一个文件夹,它们可能是隐藏的,因此请确保您选择了文件夹和搜索选项 > 查看 > 显示隐藏的文件、文件夹和驱动器(单选按钮)。

The files to permanently delete are:

要永久删除的文件是:

.gitignore (file)

.gitattributes (file)

.git (folder)

.gitignore(文件)

.gitattributes(文件)

.git(文件夹)

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.

重新打开 Visual Studio,与 Git 源代码管理不再有任何关系。如果您想将其从注册表中删除,如上所述,您可以,但除了机器的“内务管理”之外,这不是必需的。

回答by Brontomania

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

工具 -> 选项 -> 源代码管理 -> 当前源代码管理插件:无

回答by Matthew Kraus

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\LastUsedRepositoryif it's the same as the repo you are trying to remove.

  1. 删除 下的相应条目(y|ies) HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\Repositories

  2. 删除HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\General\LastUsedRepository,如果是一样的,你试图删除回购。

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.

似乎 Visual Studio 会跟踪它所看到的所有 git 存储库。即使您关闭了引用存储库的项目,旧条目可能仍会出现在列表中。

This problem is not new to Visual Studio:

这个问题对于 Visual Studio 来说并不陌生:

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

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?

从 Visual Studio 2013 解决方案中删除 Git 绑定?

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 outsideof Visual Studio to affect things insideVisual 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):

对于可能应该是内置功能的东西来说,这一切似乎都需要做很多工作。上面的“解决方案”提到修改 .git 文件等;我不喜欢必须改变Visual Studio之外的东西来影响Visual Studio内部的东西的想法。虽然我的解决方案需要进行一些注册表编辑(并且在 VS 外部),但至少这些只影响 VS。这是解决方法(阅读:hack):

Detailed Instructions

详细说明

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

在执行这些步骤之前,请务必关闭 Visual Studio 2015。

1. Open regedit.exe and navigate to

1. 打开 regedit.exe 并导航到

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio.0\TeamFoundation\GitSourceControl\Repositories

Regedit repositories for VS

VS 的 Regedit 存储库

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

您可能会看到多个“哈希”值,代表 VS 正在跟踪的存储库。

2. Find the git repository you want to remove from the list. Look at the nameand pathvalues to verify the correct repository to delete:

2. 从列表中找到要删除的 git 存储库。查看namepath值以验证要删除的正确存储库:

verify repo to delete

验证要删除的回购

3. Delete the key (and corresponding subkeys).

3. 删除键(和相应的子键)。

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

(可选:在删除之前,您可以右键单击并选择“导出”以备份此密钥,以防出错。)现在,右键单击该密钥(在我的情况下是AE76C67B6CD2C04395248BFF8EBF96C7AFA15AA9并选择“删除”)。

4. Check that the LastUsedRepositorykey points to "something else."

4. 检查LastUsedRepository键是否指向“别的东西”。

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:

如果您在上述步骤中尝试删除的存储库映射存储在 中LastUsedRepository,那么您还需要删除此密钥。首先导航到:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio.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:

并删除密钥LastUsedRepository(如果需要,VS 将重新创建密钥)。如果您担心删除密钥,您可以修改该值并将其设置为空字符串:

delete last used repo

删除上次使用的仓库

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

再次打开 Visual Studio 2015 时,git 存储库绑定不应再出现在列表中。

回答by Chris C.

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

当 Git 存储库不再是活动项目时,可以从VS-2015本地 Git 存储库列表中删除它。

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

不幸的是,Team Explorer 似乎总是保持一个存储库处于活动状态。不知道如何说服它在不切换到另一个存储库的情况下完全放手。

回答by sensei

Removing .git hidden folder worked for me.

删除 .git 隐藏文件夹对我有用。

回答by Gene S

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.

上面的答案对我不起作用。当我在 Visual Studio 中打开解决方案时,注册表项会自动重新添加。我在 Matthews 答案中的一个链接中找到了解决方案,但仍然归功于他的正确答案。

Remove Git binding from Visual Studio 2013 solution?

从 Visual Studio 2013 解决方案中删除 Git 绑定?

Remove the hidden .gitfolder in your solutionfolder.

删除.git解决方案文件夹中的隐藏文件夹。

I also removed the .gitattributesand .gitignorefiles just to keep my folder clean.

我还删除了.gitattributes.gitignore文件只是为了保持我的文件夹干净。

回答by jeanie77

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.

NoGit 扩展只是通过在每次加载解决方案时关闭 Git 源代码控制提供程序来隐藏问题。它为 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!

我通过打开另一个项目并从本地 Git 存储库中删除 Git 存储库来解决,正如 Chris C. 建议的(查看 > 团队资源管理器 > 本地 Git 存储库,选择必须删除的存储库,然后单击删除)。然后我按照 helix 的建议从项目路径中删除了 .git 文件夹。重新打开项目,最后 Git 集成消失了!

回答by erradi mourad

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

  1. 确保您没有连接到要删除的项目
  2. 项目在解决方案资源管理器中关闭

    就是这样,如果您现在重试,将启用删除操作

回答by Rodney Godfried

  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 .gitfolder
  7. Close and re-open you Visual Studio
  8. Open your project
  9. Done. :)
  1. 导航到您的项目目录
  2. 点击文件夹菜单->工具->文件夹选项
  3. 选择视图选项卡
  4. 选择在文件和文件夹下显示隐藏的文件、文件夹和驱动器
  5. 单击确定
  6. 删除.git文件夹
  7. 关闭并重新打开您的Visual Studio
  8. 打开你的项目
  9. 完毕。:)

Safe coding.

安全编码。

回答by Aman

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.

我花了一些时间从我的 Visual Studio 2015 项目中删除了 git 集成。任何时候我从 Visual Studio 中删除 git,并按照以下步骤添加 TFS - 工具 -> 选项 -> sourceControl -> 插件选择 -> Visual Studio 团队基础服务器,它曾经回来。

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

制作我的项目的物理位置 - 显示所有隐藏文件。您可以通过显示 Windows 的隐藏文件和文件夹选项来执行此操作。然后我意识到,有一个名为 .git 的隐藏文件夹。我保留了我的项目文件夹的完整备份以及 git 文件夹的任何其他必要备份(我保留了这个备份以防我的项目中断,以便我可以回到以前的状态)。

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

然后我删除了隐藏的 .git 文件夹和任何其他 .git 相关文件。

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

然后我尝试工具 -> 选项 -> sourceControl -> 插件选择 -> Visual Studio 团队基础服务器。然后我通过visual studio打开项目-文件->打开->项目/解决方案..

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

在那之后,我在解决方案资源管理器中注意到了,右键单击解决方案名称我看到“源代码控制”选项,也在项目中-右键单击我看到“向源代码控制添加soution”..这一次它没有向git添加解决方案。 .

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

从源代码管理器中删除任何 git 连接也很好..如果有任何..

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

所以最重要的是确保你的项目文件和任何其他 git 扩展名中没有隐藏的 git 文件..希望这对某人有帮助..