[英]Using both local Git and (remote) TFS with Visual Studio 2013
I started work on some code locally and used Git (Git Gui and command-line) to manage it.我开始在本地处理一些代码并使用 Git(Git Gui 和命令行)来管理它。 I've now been asked to put the project into TFS "at corporate".
我现在被要求将该项目“在公司”放入 TFS。 I can access TFS remotely using a VPN connection.
我可以使用 VPN 连接远程访问 TFS。
The code is, to VS, a single solution with multiple projects.对于 VS,代码是具有多个项目的单一解决方案。 I successfully added the solution to TFS using VS, and it seemed to find all the projects and add their .csproj files and all the code to TFS source control.
我使用 VS 成功地将解决方案添加到 TFS,它似乎找到了所有项目并将它们的 .csproj 文件和所有代码添加到 TFS 源代码管理中。
Later, when not connected to TFS (VPN off), I made a simple change and committed it to my local Git repository.后来,当没有连接到 TFS(VPN 关闭)时,我做了一个简单的更改并将其提交到我的本地 Git 存储库。 I have had nothing but frustration attempting to (connect to the VPN and) try to commit the change to TFS.
我对尝试(连接到 VPN 并)尝试将更改提交到 TFS 感到非常沮丧。
So far so good.到现在为止还挺好。
And I'm right back where I started, except that it says "Connect | {solutionName} (Local)"!我又回到了开始的地方,只是它说“Connect | {solutionName} (Local)”!
Opening the solution first doesn't help;首先打开解决方案没有帮助; when I connect to TFS the solution gets closed.
当我连接到 TFS 时,解决方案将关闭。 Closing and opening VS just has it start in "VS knows about TFS, but you're offline" mode and opening the solution with TFS active makes it switch to the Git provider in (Local) mode.
关闭和打开 VS 只是在“VS 知道 TFS,但您处于离线状态”模式下启动,并在 TFS 活动的情况下打开解决方案使其在(本地)模式下切换到 Git 提供程序。
I am very close to doing the registry hacks to disable the Microsoft Git Provider -- I've done my Git work using Git Gui and the commandline;我非常接近进行注册表黑客以禁用 Microsoft Git 提供程序——我已经使用 Git Gui 和命令行完成了我的 Git 工作; VS has not been involved.
VS 没有参与。
Am I crazy?我疯了吗? I would have thought that "develop locally using Git, connect to TFS to sync with others" was a mainstream use case for VS.
我会认为“使用 Git 在本地开发,连接到 TFS 以与其他人同步”是 VS 的主流用例。
Any assistance would be appreciated.任何援助将不胜感激。 Thanks.
谢谢。
Visual Studio only sees git repositories if the .git folder is used as the store for the git repository.如果 .git 文件夹用作 git 存储库的存储,则 Visual Studio 仅会看到 git 存储库。 So, we can fake-out VS by using a different folder for the git store.
因此,我们可以通过为 git 存储使用不同的文件夹来伪造 VS。
.git
folder to _git
( .git
dir may be hidden).git
文件夹重命名为_git
( .git
目录可能被隐藏).git
containing just the line gitdir: _git
(make the file via command line: echo gitdir: _git>.git
).git
文件夹中创建一个文本文件,其中只包含gitdir: _git
(通过命令行创建文件: echo gitdir: _git>.git
)_git
to your .gitignore
file_git
添加到您的.gitignore
文件中Now when you launch VS it will not see that git repository and will use TFS instead.现在,当您启动 VS 时,它不会看到那个 git 存储库,而是会使用 TFS。
If the server is configured for TFVC and you have a local Git repo then you cant just push from local to tfs.如果服务器配置为 TFVC 并且您有本地 Git 存储库,那么您不能只是从本地推送到 tfs。 You have two options.
你有两个选择。 You can:
你可以:
1) You can create a new team project that is configured for Git and push as normal. 1)您可以创建一个新的团队项目,该项目为 Git 配置并照常推送。
2) you can use TF-Git to push from your local git repo to the TFVC server: http://www.microsoft.com/en-gb/download/details.aspx?id=30474 2) 您可以使用 TF-Git 从本地 git 存储库推送到 TFVC 服务器: http : //www.microsoft.com/en-gb/download/details.aspx?id= 30474
I switched to using mercurial for my local repository.我改用 mercurial 作为我的本地存储库。 This features no VS integration (needs external committing) but also no VS trouble.
这没有 VS 集成(需要外部提交),但也没有 VS 问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.