2

I am working against the customer's on premises TFS server using the git-tfs bridge. Yesterday they migrated their installation to a new version + changed the URL of the server, migrating all the history and the work items to a new instance.

Is there a way to remap my existing git repository to the new default remote?

I tried to manually edit the url property of the [tfs-remote "default"] so it points to the new address and run every possible cleanup* command. However, on a fetch attempt there is a bootstrapping process adding a new tfs-remote with the old URL to the config file.

galenus
  • 2,087
  • 16
  • 24

2 Answers2

4

You've got 2 solutions:

  • The first, which should be the easier. But, because git-tfs has evolved a lot since it was implemented, I don't know if it still work even if it should...

  • Second, that will work for sure, is to update the metadata of the commit corresponding to last changeset fetched from the old TFS. It is used by git-tfs to bootstrap the new tfs-remote when none is found in the gitconfig file.

  1. Amend the git commit and replace the url in the metadata (something looking like that: git-tfs-id: [https://tfs.codeplex.com:443/tfs/TFS16]$/vtccds/trunk;C26497 ) to point to the new TFS.

  2. Create a backup of your original .git/config file:

     cp .git/config .git/config.bak
    
  3. Remove all the [tfs-remote] settings in the .git/config file.

  4. Just do a normal git tfs fetch from the command line.

Philippe
  • 28,207
  • 6
  • 54
  • 78
  • Thanks a lot, Philippe, the second option worked like a charm! – galenus Oct 26 '16 at 11:00
  • This saved me days, if not weeks, of headaches. Hope you don't mind, but I edited your answer to give a little more clarity. It took me an afternoon to figure you needed to remove all `[tfs-remote]` entries in `.git/config` and then just do a `git tfs fetch` after amending the last commit. – Greg Burghardt May 29 '19 at 18:58
  • @GregBurghardt That's perfectly fine, that's the goal of stackoverflxow. Pleased it helped! – Philippe May 29 '19 at 22:37
1

Thanks to Philippe for his answer... I would add that if you work with sever branches you need to update the config entry for each branch and add a

legacy-urls = http://old-url:8080/tfs/Projects

for each one, like

[tfs-remote "Project/branch/..."]
    url = http://newurl:8080/tfs/Projects
    repository = ....
    legacy-urls = http://old-url:8080/tfs/Projects

This will allow git-tfs to accept the checkin of these branches.

DaniCE
  • 2,412
  • 1
  • 19
  • 27