在 Visual Studio 2013 中禁用 git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20101211/
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
Disable git in Visual Studio 2013
提问by AlexanderM
I have a repository that is managed by tfs. However locally I would like to manage it via git and the push changes to tfs. Once I'm creating git repo over there VS2013 in team explorer shows this solution managed by git only. If I try to edit any file it complains that file is read only only I cannot save it in a previous version. So my question is there any way for Visual Studio 2013 to forget about git at all and manage it as tfs repository. I can manage git from command line. Or is there a way to make it to checkout files from tfs repo when I'm doing a changes?
我有一个由 tfs 管理的存储库。但是在本地,我想通过 git 管理它,并将推送更改为 tfs。一旦我在那里创建 git repo,团队资源管理器中的 VS2013 就会显示此解决方案仅由 git 管理。如果我尝试编辑任何文件,它会抱怨该文件是只读的,我无法将其保存在以前的版本中。所以我的问题是 Visual Studio 2013 有什么方法可以完全忘记 git 并将其作为 tfs 存储库进行管理。我可以从命令行管理 git。或者有没有办法在我进行更改时从 tfs 存储库中检出文件?
采纳答案by jessehouwing
For your scenario Git-tf
is probably a better solution, it will create a local git repo based on your TFVC source control folder. When you're done, you can push your changes from Git directly to TFVC from the commandline. Since you're already comfortable on the commandline, that might work out pretty well for you.
对于您的场景Git-tf
可能是一个更好的解决方案,它将根据您的 TFVC 源代码控制文件夹创建一个本地 git 存储库。完成后,您可以从命令行将更改从 Git 直接推送到 TFVC。由于您已经熟悉命令行,这可能对您很有效。
It's very hard to force Visual Studio to currently stay on Team Foundation Source Control when there is a git repo in the same folder.
当同一文件夹中存在 git 存储库时,很难强制 Visual Studio 当前留在 Team Foundation Source Control 上。
As a horrible workaround, close your solution, rename the .git
folder to _git
and reload the solution. This should bring TFVC back, but if it doesn't, then rebind the solution to TFVC if using file->source control->advanced->Change Source Control. Then after checking in, close the solution again, rename _git
back to .git
and reload.
作为一个可怕的解决方法,关闭您的解决方案,将.git
文件夹重命名为_git
并重新加载解决方案。这应该会带回 TFVC,但如果没有,则在使用file-> source control-> advanced-> 时将解决方案重新绑定到 TFVC Change Source Control。然后签入后,再次关闭解决方案,重命名_git
回.git
并重新加载。
As Ed mentions in the comments, you can move your .git folder to another folder, like this:
正如 Ed 在评论中提到的,您可以将 .git 文件夹移动到另一个文件夹,如下所示:
\MyProjects
\GitRoot
| \.git
\MySolution
\MyFirstProject
\MySecondProject
This allows Visual Studio to use the TFVC bindings and you can tell the git commandline that the .git directory is elsewhere using the git --git-dir=\MyProjects\GitRoot\.git
command argument.
这允许 Visual Studio 使用 TFVC 绑定,并且您可以使用git --git-dir=\MyProjects\GitRoot\.git
命令参数告诉 git 命令行 .git 目录位于其他地方 。
You can set an environment variable named GIT_DIR
to fix that in one go, as @hlovdal mentions.
GIT_DIR
正如@hlovdal 所提到的,您可以设置一个名为的环境变量来一次性解决该问题。
And there is another trick that @Eric mentions which creates a text file names .git
that has the following in it:
还有@Eric 提到的另一个技巧,它创建了一个.git
包含以下内容的文本文件名:
gitdir: _git
Rename .git folder to _git, then make sure you add _git
to .gitignore
将 .git 文件夹重命名为 _git,然后确保添加_git
到.gitignore
Tip:to create a file that starts with a .
from Windows Explorer you can use the New/Text Documentoption:
提示:.
要从 Windows 资源管理器中创建以 a 开头的文件,您可以使用New/Text Document选项:
Then name the file .git.
(make sure the Show file Extensions option is ticked):
然后命名文件.git.
(确保勾选显示文件扩展名选项):
回答by Eric
The solution outlined here works well for me: How can you disable Git integration in Visual Studio 2013 permanently?
此处概述的解决方案对我很有效:如何永久禁用 Visual Studio 2013 中的 Git 集成?
Essentially:
本质上:
- Rename .git folder to _git, as @jessehouwing says
- Create a text file called .git containing just the line "gitdir: /Path/To/_git"
- Add _git to .gitignore
- 正如@jessehouwing 所说,将 .git 文件夹重命名为 _git
- 创建一个名为 .git 的文本文件,只包含“gitdir: /Path/To/_git”行
- 将 _git 添加到 .gitignore
Visual Studio will now only use TFS and git works properly as well.
Visual Studio 现在将只使用 TFS 并且 git 也能正常工作。
回答by Aghilas Yakoub
I suggest theses steps :
我建议这些步骤:
- Go to
TOOLS Tab
in Visual Studio - Select
Options
items - On the left, select
Source Control
- In the
Plugin Selection
Item, EnterNone
in the dropdownlist associated
TOOLS Tab
在 Visual Studio 中转到- 选择
Options
项目 - 在左侧,选择
Source Control
- 在
Plugin Selection
Item 中,None
在关联的下拉列表中 输入
回答by Earlz
You can remove the git support from Visual Studio 2013 using some registry hacks. It's of course a bit risky, but I've yet to have any problems after removing git support using this method:
您可以使用一些注册表技巧从 Visual Studio 2013 中删除 git 支持。这当然有点冒险,但是在使用这种方法删除 git 支持后我还没有遇到任何问题:
http://blog.markrendle.net/disable-the-git-source-control-add-in-in-vs2013-permanently/
http://blog.markrendle.net/disable-the-git-source-control-add-in-in-vs2013-permanently/
It boils down to just removing everyhing associated with the GUID {11B8E6D7-C08B-4385-B321-321078CDD1F8}
归结为只是删除与 GUID 相关的所有内容 {11B8E6D7-C08B-4385-B321-321078CDD1F8}
回答by Harinath
Bad Solution: Close your solution, rename the .git folder to _git and reload the solution worked for me. Thanks jessehouwing.
错误的解决方案:关闭您的解决方案,将 .git 文件夹重命名为 _git 并重新加载对我有用的解决方案。谢谢 jessehouwing。