简体   繁体   English

如何使我的项目脱离Git并进入TFS?

[英]How do I get my project out of Git and into TFS?

Last week I started a small project in Visual Studio 2017. Got it to the point where I want to check it into source control and share it with my co-workers. 上周,我在Visual Studio 2017中启动了一个小项目。将其保存到我想将其检入源代码管理并与同事共享的地步。 The problem is that somehow (man, I wish I knew how so that I could avoid doing this again) it got checked into Git on my machine. 问题在于(以某种方式(伙计,我希望我知道如何避免再次执行此操作))将其检入计算机上的Git。 It isn't going to do anybody any good being checked into Git on my machine. 在我的计算机上检入Git不会对任何人有任何好处。 And we've standardized on TFS. 而且我们已经在TFS上进行了标准化。 I've tried removing the .gitignore and .gitattributes files from the root folder of my VS 2017 project, but that didn't work. 我已经尝试从VS 2017项目的根文件夹中删除.gitignore和.gitattributes文件,但这没有用。 (Besides, the instant I got back into the project in VS 2017, those 2 files were recreated.) (此外,当我回到VS 2017中的项目的那一刻,就重新创建了这两个文件。)

So, how do I get the solution and project out of Git so that I can get it into TFS/TFVC? 那么,如何从Git中获取解决方案和项目,以便将其导入TFS / TFVC?

The problem is that somehow [...] it got checked into Git on my machine. 问题在于它以某种方式被检入了我机器上的Git。

That is probably the best thing that has happened to you! 那可能是发生在你身上的最好的事情! Follow the Microsoft example and standardise on git... 遵循Microsoft示例并在git上进行标准化...

But, anyway,... Find the '.git' folder which is at the root directory (and that could be hidden), delete it and check your project in TFVC. 但是,无论如何,...找到根目录中的“ .git”文件夹(可以隐藏),将其删除并在TFVC中检查您的项目。

To get the solution out of git: 要从git中获得解决方案:

  1. In File Explorer open the folder where the solution is stored. 在文件资源管理器中,打开存储解决方案的文件夹。
  2. Delete .git, .gitignore, .gitattributes files/folder 删除.git,.gitignore,.gitattributes文件/文件夹

To add the solution to TFS/TFVC source control: 要将解决方案添加到TFS / TFVC源代码管理中,请执行以下操作:

  1. Open project in VS 2017 在VS 2017中打开项目
  2. Open Team explorer and connect to a TFVC team project 打开团队资源管理器并连接到TFVC团队项目
  3. Right click solution > Add to source control 右键单击解决方案>添加到源代码管理

TFS supports Git too, so you could push it to a git repository in TFS: TFS也支持Git,因此您可以将其推送到TFS中的git存储库:

  1. Create a new git repository in TFS 在TFS中创建一个新的git存储库
  2. Open VS 2017 打开VS 2017
  3. Open Team explorer 开放团队资源管理器
  4. Click manage connections 点击管理连接
  5. Click Add in Local Git Repositories section 单击“在本地Git存储库中添加”部分
  6. Double click the added repository 双击添加的存储库
  7. Click Home > Settings> Repository Settings 单击主页>设置>存储库设置
  8. Click Add in Remotes section 单击“添加到遥控器”部分
  9. Specify git repository (step 1) and name 指定git仓库(步骤1)和名称
  10. Click Home > Sync 单击主页>同步
  11. Click Push and select the repository (step 9) 单击推并选择存储库(步骤9)

I deleted all the .git files from the solution directory and still had issues... 我从解决方案目录中删除了所有.git文件,但仍然有问题...

Git kept defaulting to the source control even after restarting and setting source control to visual studio. 即使在重新启动源控件并将其设置为Visual Studio之后,Git仍默认使用源控件。

Fix: I then noticed that I wasn't signed into TFS! 修正:然后我注意到我没有登录TFS!

After I signed into TFS in Team Explorer GIT stopped defaulting when I tried to add the solution to source control. 当我在Team Explorer中登录TFS后,尝试将解决方案添加到源代码管理时,GIT停止了默认设置。 I was able to add to TFS. 我能够添加到TFS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM