2

Where are "Local Git Repository" paths stored? enter image description here

amit jha
  • 398
  • 2
  • 6
  • 22

4 Answers4

2

Visual Studio 2015 stores the list of GIT Repositories in the Registry:

Computer\HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\Repositories

David Kujawski
  • 319
  • 1
  • 7
2

I'm working with VS2017 and after a bit of digging, I think I may have found where Visual Studio is storing the information. Go to %AppData%\Microsoft\VisualStudio\15.0_{instanceId}\Team Explorer\TeamExplorer.config.

That file has information like the following in it:

    <!--This configuration file specifies the previously-configured connection details for Team Foundation Server.-->
<server_list>
    <server url="http://mytfsserver:8080/tfs" current="yes">
        <collection guid="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx" url="http://mytfsserver:8080/tfs/defaultcollection" name="mytfsserver\DefaultCollection" current="yes" autoload="yes">
            <project projectUri="vstfs:///Classification/TeamProject/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx" name="MyTeamProject" capFlagsScc="1" supportsGit="yes" active="yes" team="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx">
                <repository type="2" name="MyGitRepo" guid="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx" activeClone="C:\Repos\MyGitRepo" isFork="False" />
            </project>
        </collection>
    </server>

Based on this, you can tell that MyGitRepo is stored in C:\Repos\MyGitRepo. The best way I can find to get the Visual Studio instance ID is by calling:

 "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property instanceId
Basim
  • 221
  • 2
  • 5
1

As far as I know, Visual Studio likely does not have much to do with where Git is storing its metadata. Git maintains a hidden folder called .git at the root level of every local repository. In it is contained all the objects, refs, blobs, hooks, etc. which get used in Git.

Following the interface which Git exposes, if you want to see the files corresponding to a local branch you have, you can checkout that branch, or possibly checkout individual files of interest.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • But when we do "Refresh" on "Team Explorer - Connect" Document window, it refreshes/ finds the git repositories by digging all the `.git` folders in the paths specified under "Local Git Repository". So, I thought it may be saving somewhere. I searched the registry, but wasn't able to get a clue. – amit jha Oct 11 '16 at 09:51
1

Well. It seems that Visual Studio 2019 has moved this information yet again. It's now in the VS private registry. Based on this post and this post, I used the following code snippet to find the local Git repositories:

        const string GitRepoRoot = @"TeamFoundation\GitSourceControl\Repositories";
        ExternalSettingsManager ext = ExternalSettingsManager.CreateForApplication(@"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe");
        SettingsStore store = ext.GetReadOnlySettingsStore(SettingsScope.UserSettings);
        var keyNames = store.GetSubCollectionNames(GitRepoRoot);
        foreach (var key in keyNames)
        {
           Console.WriteLine(store.GetString($"{GitRepoRoot}\\{key}", "Name"));
           Console.WriteLine(store.GetString($"{GitRepoRoot}\\{key}", "Path"));
        }
Basim
  • 221
  • 2
  • 5