How to move a project from Git to TFS in Visual Studio

42,082

Solution 1

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.

Solution 2

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.

Solution 3

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

Solution 4

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.

Share:
42,082
user2900166
Author by

user2900166

Updated on March 31, 2021

Comments

  • user2900166
    user2900166 about 3 years

    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!

  • Richard Banks
    Richard Banks over 9 years
    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.
  • Horizon_Net
    Horizon_Net over 9 years
    Thanks @RichardBanks for mention it. This can be an important point.
  • MushyPeas
    MushyPeas over 7 years
    Thanks, the accepted answer didn't help at all, this was the right answer for me.
  • Mike Gledhill
    Mike Gledhill over 6 years
    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....
  • Pablo Boswell
    Pablo Boswell over 6 years
    For me, this just kept resorting back to a Git source control. I had to recreate the solution from scratch
  • Robert Swilley
    Robert Swilley about 6 years
    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
  • Some_Yahoo
    Some_Yahoo over 5 years
    Here's the procedure.
  • Roald
    Roald over 5 years
    Worked for me. There was a hidden folder named .git which you should not forget to delete.
  • Roald
    Roald over 5 years
    The .git folder is a hidden one for the ones not seeing it.
  • BBQ Singular
    BBQ Singular over 5 years
    For me, it was necessary to open VS, change to TFS, establish a connection to my server, then open the project. Opening it earlier caused it to connect to a local Git repo.
  • Soren Bjornstad
    Soren Bjornstad over 4 years
    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.
  • Victor_Tlepshev
    Victor_Tlepshev about 4 years
    Worked for me on VS 2019 Pro. Like @Roald the folder .git happened to be hidden.