在Visual Studio 2013中禁用git [英] Disable git in Visual Studio 2013

查看:191
本文介绍了在Visual Studio 2013中禁用git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由tfs管理的存储库。不过,我希望通过git来管理它,并推送到tfs。一旦我在那里创建git repo,在团队资源管理器中的VS2013显示这个解决方案只由git管理。如果我尝试编辑任何文件,它会抱怨文件只读,我无法将其保存在以前的版本中。所以我的问题是,Visual Studio 2013有没有办法忘记git,并将其作为tfs存储库进行管理。我可以从命令行管理git。或者有什么办法可以让我在修改tfs repo时检出文件?

Git-tf 可能是更好的解决方案,它会根据您的TFVC源代码管理文件夹创建一个本地git仓库。完成后,您可以通过命令行将您的更改从Git直接推送到TFVC。既然你已经习惯了命令行,那对你来说可能会很好。



当Visual Studio当前停留在Team Foundation Source Control上时很难在同一个文件夹中有一个git仓库。






作为一个可怕的解决方法,关闭您的解决方案,重命名 .git 文件夹复制到 _git 并重新加载解决方案。如果使用文件 - > 源代码管理 - > 高级,则应该使TFVC恢复,但如果不包含,则将解决方案重新绑定到TFVC。 - > 更改来源控制。然后在签入后再次关闭解决方案,将 _git 重命名为 .git 并重新加载。






Ed在评论中提到,您可以将.git文件夹移动到另一个文件夹,如下所示:

  \ MyProjects 
\GitRoot
| \.git
\ MySolution
\ MyFirstProject
\ MySecondProject

这允许Visual Studio使用TFVC绑定,并且可以使用 git --git-dir = \ MyProjects \GitRoot \来告诉git命令行.git目录在别处.git 命令参数。



您可以设置一个名为 GIT_DIR 的环境变量来修复在@Hlovdal提到的一次性去除。






另外还有一个技巧是@Eric提到了创建文本文件名称 .git ,它包含以下内容:

  gitdir:_git 

将.git文件夹重命名为_git,然后确保添加 _git to .gitignore



提示:创建一个文件从Windows资源管理器的开始,您可以使用新的 / 文本文档选项:





然后命名文件 .git。(确保Show file Extensions选项已勾选):




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?

解决方案

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.

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.


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.


As Ed mentions in the comments, you can move your .git folder to another folder, like this:

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

You can set an environment variable named GIT_DIR to fix that in one go, as @hlovdal mentions.


And there is another trick that @Eric mentions which creates a text file names .git that has the following in it:

gitdir: _git

Rename .git folder to _git, then make sure you add _git to .gitignore

Tip: to create a file that starts with a . from Windows Explorer you can use the New/Text Document option:

Then name the file .git. (make sure the Show file Extensions option is ticked):

这篇关于在Visual Studio 2013中禁用git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆