Posted tagged ‘Git’

Move from GitHub to TFS Git Repository

May 13, 2013

I really like Git and GitHub, but I love TFS.  Now that TFS has a Git repository I wanted to make the move back over to TFS.  Here are the steps to move from probably any Git Repo to TFS Git.

  1. Create a Git Repository in TFS
  2. Set your Alternate Credentials in TFS. TFSAlternateCredentials
    Click on Code
    Select Clone from Right
    Click Profile
    Set User Name and Password to be used later
  3. Open Git Command window such as Git Bash
  4. Move to a directory that you want to clone your code to for the transfer.
  5. Clone your GitHub repo locally.

    git clone https://github.com/%5Busername%5D/%5Bproject%5D

  6. Rename the GitHub remote repo to upstream

    git remote rename origin upstream

  7. Set the TFS Git remote repo as the origin

    git remote add origin https://%5Baccountname%5D.visualstudio.com/DefaultCollection/_git/%5Bteamproject%5D

  8. Push your changes to TFS Git

    git push origin master

At this point you should be able to see your commit history in TFS Git repository.  Beautiful right?  I haven’t tried it yet, but I believe you can keep your original GitHub repo if you want and pull in changes with the following commands.

  1. Pull from upstream which is your GitHub repo.

    git pull upstream master

  2. Push the changes to origin which is TFS Git.

    git push origin master

Let me know if it works out for you.