vossad01
vossad01

Reputation: 11958

Extra TFS features missing from git repository hosted in TFS

When you use Git as the source code provider for a TFS project, Visual Studio usually makes available a number of features in Team Explorer that are not there for a Git project not hosted in TFS. These include Work Items, Builds, Reports, and links to Web Portal features.

Picture showing some of the added features

I added a connection to the TFS project. However, I cloned from a network-local Git mirror that I created and to not have these extras. I created the mirror because the TFS server is over the Internet from here and our connection is slow. Basically the mirror is to take the Team Foundation Server Proxy that can be used when using TFVC.

If I clone from TFS then the features are available but I do not want push/pull to happen directly against the TFS server.

How can I keep these extra TFS features accessible while still making use of the mirror?

Upvotes: 2

Views: 364

Answers (1)

vossad01
vossad01

Reputation: 11958

The availability of these features seem to be tied to the origin remote of the Git repository. origin must be set to the TFS server.

When you clone from a different location, that location will be origin by default. Similarly if you have a repository cloned from TFS but then change origin to a different server (even if you keep the TFS server as a differently named remote) you loose these features in Visual Studio.

You will need to use the git command line tools to fix this as there is not currently a Visual Studio GUI for managing remotes.

If you cloned from the mirror, restoring the functionally consist of the following:

git remote rename origin mirror
git remote add origin <TFS Clone URL>

By renaming the origin remote, the existing branches had their tracking updated appropriately, so push/pull on those branches will happen against mirror

You can get the <TFS Clone URL> from an existing clone (run git remote -v in the repository) or from the Team Foundation Server Web Portal. In Web Portal there is a 'Clone' button that pops up the needed url under 'Code' / 'Explore'. It is usually of the form http://<server>:<port>/tfs/<collection>/_git/<project>.

If you cloned from TFS, but want a different remote (the mirror) to be the default for push/pull:

git remote add mirror <Clone URL for mirror>
git branch --set-upstream-to=mirror/master master

This adds the mirror as a new remote called mirror. Then it makes the master branch track mirror/master instead of origin/master which will cause Visual Studio to use mirror when you click push or pull in Visual Studio.

You will need to repeat the last line of the above for every other existing local branch that you want to have push/pull to the mirror rather than the TFS server.

Note: This still leave the limitation that if you publish branched through Visual Studio it sets the upstream to origin so you would have to go out to command line to reset the upstream to mirror. You CAN however, to a "Push To" to mirror on the 'Unsynced Commits' tab without publishing the branch. This at least makes it workable, but is unfortunately inconsistent with how branches are usually published. Hopefully newer versions of TFS either let these extra features work if ANY remote is the TFS server, or give an option of which remote to publish a new branch to.

Upvotes: 1

Related Questions