简体   繁体   中英

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.

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.

Thanks to Philippe for his answer... I would add that if you work with severl branches you need to update the config entry for each branc 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM