40

I have a project that I've been working on for some time now and I just cannot make Git work for me. I've spent a day trying to recover lost code and I am done with Git.

Can anyone tell me how to move an existing project into TFVC? I have a Visual Studio Online account with a TFVC project all set up for this task, but I cannot figure out how to change the source control settings so that the project is no longer tied to Git.

I am currently developing on VS 2013.

Any help is greatly appreciated!

user2900166
  • 499
  • 1
  • 5
  • 11
  • possible duplicate of [How to configure Visual Studio to use different source control providers](http://stackoverflow.com/questions/5994009/how-to-configure-visual-studio-to-use-different-source-control-providers) – Roman Sep 14 '14 at 15:44

4 Answers4

96

Just delete the .git folder (this one is normally hidden) in the root folder (f.e. via Windows Explorer). This deletes all things related to git. After that add the code to your TFS project and check it in into TFS.

Horizon_Net
  • 5,959
  • 4
  • 31
  • 34
  • 10
    Note that this approach will only check in your current code, not any history. In your case, that might be OK :-). If you do want the history, use the git-tf utility to push your code and history to the TFVC repository. – Richard Banks Sep 17 '14 at 01:07
  • Thanks @RichardBanks for mention it. This can be an important point. – Horizon_Net Sep 17 '14 at 07:54
  • 1
    Nope, didn't work for me. I would remove the .git folder, ask to connect to our company's TFS server... at which point VS2017 would just unload the solution completely and send me back to the VS Home screen... Over, and over again.... – Mike Gledhill Oct 24 '17 at 11:55
  • You have to use Source Control under File -> Source Control -> Add Project to Source Control to add to TFS. If you use File -> Add to Source Control it assumes git – Robert Swilley Mar 17 '18 at 16:10
26

Here's the procedure.

  1. Right click the project name in solution explorer.
  2. Open Folder in File Explorer.
  3. Close Visual Studio.
  4. Delete the folder and files that have .git in the name.
  5. Open Visual Studio and load the project.
  6. Tools->Options->Source Control.
  7. Pick TFS.
  8. Go to Team Explorer tab.
  9. Connect to your TFS server (I assume you have already created a repo)
  10. Pick the right repo.
  11. Right click solution in solution explorer Add to Source Control.
Some_Yahoo
  • 509
  • 6
  • 9
8

You cant just change from Git to TFVC as this option is bound to the Team Project. You will need to create a new Team Project making sure that you select TFVC as the provider.

  1. Connect to that new Team Project and create a local workspace.
  2. Create the folder structure you need. I would recommend $/newTP/MyPeoduct/Rx.x/
  3. Copy the files from the Git repo (except .git) to this location.
  4. Open the solution and right click on it and select "add to source control"

You should now be migrated...

  • 1
    Thanks, the accepted answer didn't help at all, this was the right answer for me. – MushyPeas Nov 26 '16 at 14:25
  • For me, this just kept resorting back to a Git source control. I had to recreate the solution from scratch – Pablo Boswell Nov 15 '17 at 18:21
  • 1
    This is the answer to a different problem. The OP asked how they could unbind a project from source control *in Visual Studio on their local machine* so they can upload it to a particular team project which is already configured correctly. This answer describes how you would go about moving a project if you had misconfigured *your Team Foundation Server/VSTS instance* to use the wrong source control system. – Soren Bjornstad Aug 12 '19 at 13:18
3

VS2017 - I had the same issue listed above and after deleting the .git folder in the root directory of my project folder, clicking Add Project to Source Control only created a new .git, from both Solution Explorer and the File menu. I got mine to work by deleting the .git folder, going into Team and Manage Connections and opening the TFS Project I wanted to add it to. I then went to File->Source Control->Add Solution to Source Control and it worked.

JR Berg
  • 31
  • 1