1

I have a TFS hosted git repo (e.g. https://tfsfoo.com/_git), and I need to move it to another TFS host (e.g. https://tfsbar.com/_git)

My solution is to do the following (modified based on suggestion below to use --mirror):

  1. git clone https://tfsfoo.com/_git/proj --mirror
  2. Loop through branches (git branch -r) and then git branch --track each of those (as in this post)
  3. Note that I had already pushed to the new repo (without branches), so --mirror wasn't an option.
  4. git pull
  5. git remote set-url origin https://tfsbar.com/_git/proj
  6. git push --all --follow-tags

Now - I know I can just try this to see if it works (and I probably will while I wait for answers), but given that there are multiple ways to do just about everything in git, I'm wondering if there's a better way - or more importantly, if there's anything wrong with this approach (I'm relatively new to git).

Community
  • 1
  • 1
Alan
  • 1,045
  • 7
  • 14

2 Answers2

3

Since you have network access to the second server, then yes, pushing is the easiest way.

To create local branches for all remote tracking branches, you can use the one-liner I usually use at "git pull all branches from remote repository".

The alternative is to git clone --mirror the first repo, and push it to the second server as in this answer.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • ahh - I didn't know about --mirror (nor did I find the first link in my search, as this is probably a duplicate of that question). – Alan Jun 07 '14 at 16:31
  • @Alan no, your question illustrates the alternative technique, when you stay in the same local repo (instead of making a bare repo with the `git clone --mirror`) – VonC Jun 07 '14 at 16:33
0

You can achieve this with git-copy.

git copy https://tfsfoo.com/_git https://tfsbar.com/_git
Quanlong
  • 24,028
  • 16
  • 69
  • 79