Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does visual studio 2013 remember the mapping between a remote git/tfs repository and a local path?

How does Visual Studio remember which GIT/TFS (Git over TFS) repository on a given team project has been cloned to the local machine?

While browsing the git repositories on a Team Project, Visual Studio shows an icon on the right of the repos which haven't been cloned yet.

an image of the git/visual studio integration: which repositories are available, and which ones have been cloned

This icon disappears once the repository has been cloned on the local machine. From this point on, Visual Studio saves a mapping (remote repository, local path) somewhere.

  • Where are these mappings saved?
  • Is there an API exposing/accessing this information?
like image 354
nilleb Avatar asked Mar 19 '23 03:03

nilleb


1 Answers

Detailed description -- so far

The file %APPDATA%\Microsoft\VisualStudio\12.0\Team Explorer\GitTeamProjects.config seems to contain this information.

<?xml version="1.0" encoding="utf-8"?>
<!--This file caches information about Git team projects.-->
<collection_list>
  <collection guid="9737cdde-596c-43f5-bea7-eadbe664f536" collectionUri="http://tfs:8080/tfs/tahaa" />
  <collection guid="d3ee7565-1499-4a84-9eb3-7e97bf3a932e" collectionUri="http://tfs:8080/tfs/test2013">
    <project name="_TestBuilds" projectUri="vstfs:///Classification/TeamProject/2706587b-a4b3-4404-a5b1-0e8f210eddc5">
      <repository name="SetupConfigurator" guid="54ff434a-bced-4457-8b7c-7f2ab2577514" LastActiveClone="K:\TFS\SetupConfigurator" />
      <repository name="Trunk" guid="a08927d7-4e0a-4035-ae5d-964bf03926a4" LastActiveClone="K:\_TestBuilds" />
      <repository name="IntegrationTests" guid="37286658-9138-4bab-bc93-9eeb67addd36" LastActiveRepo="Yes" LastActiveClone="K:\GitRepositories\IntegrationTests" />
    </project>
  </collection>
</collection_list>

I've modified it once, and Visual Studio seems to have lost the mappings then.

But, after having restored it to the original content, Visual Studio doesn't seem to use it again.

I have also found a list of repositories stored in the registry (in HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\TeamFoundation\GitSourceControl\Repositories).

Repositories
   hash
     Name(REG-SZ)
     Path(REG-SZ)
   hash
     Name(REG-SZ)
     Path(REG-SZ)
   ...

Visual Studio 2015

The file name has slightly evolved: %APPDATA%\Microsoft\VisualStudio\14.0\Team Explorer\TeamExplorer.config

The registry path has evolved to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\Repositories

How to refresh the Visual Studio mappings

Let's suppose that all of your git repositories reside in the same folder, on the local machine, and that the path to this folder is K:\GitRepositories

  1. open Visual Studio 2015
  2. open the Team Explorer
  3. press the plug icon
  4. in the section "Local Git Repositories", click the button Add
  5. type 'K:\GitRepositories' in the textbox, then 'Add'

Done! Your mappings have been updated.

like image 118
nilleb Avatar answered Mar 22 '23 10:03

nilleb