Search code examples
gitgit-tfs

Change default remote for git-tfs repository


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.


Solution

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