Use git-tf to bridge between existing TFS repository and existing git repository

Feb 5, 2013 at 9:41 AM
I have the following scenario:

I am currently using git along with git flow. The official VCS however is TFS. In the past I periodically dumped the latest sources in TFS using git-tfs, to adhere to the official standards.

That worked quite well, because I was the only developer on the project.
However, that changed now. The new developer won't be using git, he will be using TFS. Eventually, he will be taking over the project, so branching and merging should happen in TFS.

The branching concept is pretty simple:
  1. There is a Main branch. Here the version should be bumped and bugs preventing shipping should be fixed. Changes will be merged back into Development ASAP.
  2. The second branch is Development. The is the branch for vNext. When work is done for vNext, this branch is merged into Main.
  3. For larger, disrupting changes, optional Feature branches can be spun up based on Development.
  4. For hotfixes, hotfix branches can be created from Main.
What I envision is the following:
  1. I can somehow get the existing git master into TFS and "attach" it to Main.
  2. I can create a branch of TFS's Main branch to create the Development branch. That's important, otherwise I can't merge changes between the two branches in TFS.
  3. I can add the commits between git master and git develop to the Development branch in TFS and attach it to the git develop branch.
What would be the prefered approach for a scenario like that?
Developer
Feb 6, 2013 at 3:02 PM
Hi,

Unfortunately, current implementation of Git-TF ensures synchronization only between a TFS folder (or a TFS Branch in your case) and the “master” branch of a Git repository. What about the following workaround:
  1. Create two (bare) Git repositories as buffers for synchronization with TFS branches – each with a branch master mapped to a corresponding Branch in TFS.
  2. Create you working Git repository with Main and Development branches mapped to master branches of the corresponding buffer repositories.
                   .--------------------------------.
                   |              TFS               |
                   |                                |
                   |     Main          Development  |
                   `--------------------------------‘
                          A                A        
                          |                |
                 .--------'                `-------.
                 |                                 |
                 V                                 V
.--------------------------------. .--------------------------------.  
|             master             | |             master             |  
|                                | |                                |  
|            Main.git            | |       Development.git          |  
|             (bare)             | |             (bare)             |  
`--------------------------------‘ `--------------------------------‘  
                 A                                  A
                 |                                  |
                 `-------.                 .--------'
                         |                 |         
                         V                 V         
                   .--------------------------------.
                   |     Main          Development  |
                   |                                |
                   |             .git               |
                   `--------------------------------‘
                   |         Working folder         |
                   `--------------------------------‘
Or you might simply have 2 git-tf normal repos one pointing to Main and another pointing to Development, that way he only has to manage 2 repos and not 3 repos.

Looks a bit clumsy,… but maybe it could help you to survive until you pass the project to the guy using TFS only?

Alex
Feb 6, 2013 at 5:28 PM
Edited Feb 6, 2013 at 5:29 PM
Alex,

thanks for your answer. I have no problem with using proxy repositories. But I fail to see how that helps me to continue to use my existing git-repository.
Could you please elaborate?

Thanks
Developer
Feb 7, 2013 at 2:28 PM
Hi,

I presumed that the normal repository. i.e.
                   .--------------------------------.
                   |     Main          Development  |
                   |                                |
                   |             .git               |
                   `--------------------------------‘
                   |         Working folder         |
                   `--------------------------------‘
is exactly your existing git-repository.
Feb 7, 2013 at 2:39 PM
Edited Feb 7, 2013 at 3:56 PM
Ok, that makes sense. How would I connect those three git repositories and the TFS repository? With which commands?

Thanks
Developer
Feb 12, 2013 at 5:45 PM
Hi,

Sorry for the delay with the answer. You could connect two bare repositories with TFS by using Git-TF configure command with the --git-dir parameter:
git init --bare <Main.git-path>
git init --bare <Development.git-path>
git tf configure <tfs-collection-url> $/<Main-branch-path> --git-dir=<Main.git-path>
git tf configure <tfs-collection-url> $/<Development-branch-path> --git-dir=<Development.git-path>
and define remotes in your working repository:
git remote add --tags origin_Main <Main.git-path>
git remote set-url --push origin_Main <Main.git-path>
git remote add --tags origin_Development <Development.git-path>
git remote set-url --push origin_Development <Development.git-path>
Honestly, I'm not sure if git allows to connect your working repository with the buffer bare repositories by using commands. It looks like for tracking branches git requires them to have identical names. But you could specify branches in push/pull commands explicitly. E.g.
git push origin_Main +Main:master
git pull origin_Main +master:Main
Alex