Move from GitHub to TFS Git Repository

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.

 


Explore posts in the same categories: TFS

Tags: ,

You can comment below, or link to this permanent URL from your own site.

6 Comments on “Move from GitHub to TFS Git Repository”

  1. Stephen Jones Says:

    Have you any experience with using GIT in TFS with PowerBuilder?

    • Tom Krueger Says:

      Hi Stephen,

      I personally don’t have experience using GIT in TFS with PowerBuilder, but you certainly should be able to if you use a separate Git Client or if the PowerBuilder IDE has a Git integration I assume it would work as my understanding Git repo’s have a standard interface. Here is what I suggest. Start by using a Git Client, there are command line tools but I personally like Source Tree by Atlassian. If that works then I would connect up the PowerBuilder IDE if it has Git integration.

      Good Luck,
      Tom


  2. Worked great for me! Much simpler than other similar posts on the topic.

  3. Suman Says:

    How can I keep my branches intact using the above. It only works for Master.

    • Tom Krueger Says:

      Hi Suman,

      I do not know how to keep your branches intact when moving from one Git Repo to another. I also would not advise this. I don’t know your situation, but I would advise getting all branches merged back to master first and then moving over to TFS Git.

      Thanks for commenting,
      Tom


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: