cloning a git-tfs central repo, and hiding TFS

886 views Asked by At

I have a code repository in TFS (Microsoft Team Foundation Server). I can use git-tfs to convert this to a git repository.

But what I want to do is set up one central git repo that pushes to TFS, and have all developers clone that git repo and not be able to push to TFS. As far as anyone "downstream" from the central repo., I don't want any indication there's a TFS repo at all.

Since the TFS server information is included in the repo produced by git-tfs, how can I do this?

2

There are 2 answers

0
Ivan Danilov On

There's several problems need to be solved for this to work. Most prominent is mapping from git users to TFS credentials that will be used when checking in changes back to TFS.

And other troublesome thing is possible conflict with other TFS users (i.e. if someone decides to push things to TFS directly).

That is why it wasn't developed as part of git-tfs I believe (at least that is why I didn't added this feature several months ago).

If you're ok with having TFS login/password pairs in plain text file, and you can ensure conflict-free workflow (e.g. to prohibit checkins to TFS in any other way except through your git central repository) - you can implement what you need with commit hooks or even with simple scheduler (so pushing will be not immediate, but deferred and asynchronous, thus speeding up pushing to git central repository significantly).

Actual script should be pretty straightforward, but nobody bothered to write one yet (at least I don't know of such thing).

0
CincauHangus On

Firstly, strip off TFS metadata from your commits using the --no-metadata flag. Then use the --authors="path-to-authors.txt" flag to map your TFS users to current.

git tfs clone http://tfs:8080/tfs/DefaultCollection $/Project1 --authors="c:\project1\authors.txt" --no-metadata

In your authors.txt, map your users TFS id to their email like this:

TFSDOMAIN\peter.pan = Peter Pan <[email protected]>

After cloning the repo, run git tfs bootstrap and remove the TFS configuration in your .git/config file. You now should not be able checkin to TFS but still be able to share the repo among your developers.

More details on git tfs clone https://github.com/git-tfs/git-tfs/blob/master/doc/commands/clone.md