This project is read-only.

Merge TFS and git repos

Mar 14, 2013 at 5:04 AM
I've created a new git repo and created some files in it.
Later on I wanted to check it in into a new TFS project, so I tried to follow these steps:
git tf configure http://myserver:8080/tfs/mycollection $/TeamProjectA/Main git tf pull git commit -a -m "merge commit" git tf checkin git push On second step (pull) it started to complain that it is a new repo and nothing to pull.
Then I've checked in into TFS manually.

Now I can't check-in into TFS my local git changes with this result:
git-tf: The path C:....git\tf\6a7fe27 is already mapped in workspace ...

Trying to clone TFS into the same repo would result in this error:
git-tf: destination 'C:...' already exists and is not empty.

How would I achieve this scenario:
Pull TFS repo manually, then initialize local git repo, link those two.

I need this scenario as everything is checked in into TFS including tools, so to install dev environment we need to pull everything from TFS, then run tools (including git and git-tf) to initialize the environment.
Mar 14, 2013 at 8:59 PM
Hello phwp,

I think what you are looking for is the following command:
git tf clone http://myserver:8080/tfs/mycollection $/TeamProjectA/Main 
What this will do is clone the code already existing in TFS to a local git repository. You can them do your changes locally in git and commit them. To push them back up to TFS you need to execute:
git tf checkin
Please let us know if this does not resolve your problem.

Thanks,
Youhana
Mar 14, 2013 at 9:00 PM
Hi phwp,
Then I've checked in into TFS manually.
Now I can't check-in into TFS my local git changes with this result:
git-tf: The path C:....git\tf\6a7fe27 is already mapped in workspace ...
As far as I understand, you've created a TFS workspace that maps your working folder. Now Git_TF cannot create its own mapping needed to check in commits to TFS. Could you try and delete the existing TFS workspace or its mapping for the git repository?

Sincerely yours
Alex
Mar 14, 2013 at 9:50 PM
Hi,
I need this scenario as everything is checked in into TFS including tools, so to install dev environment we need to pull everything from TFS, then run tools (including git and git-tf) to initialize the environment.
Is it a need to have tools in the git repository? You might download them to some other folder and clone to a git repository only the sources that developers supposed to work on.

Another workaround could be as following: you first download git-tf to a separate temporary folder and use this copy to perform clone from TFS. After that you might delete the temporary copy of git-tf:
md C:\_git-tf_
tf workspace /new /collection:http://yourServer:8080/tfs/yourCollection tfsWorkspace
tf workfold /map /workspace:tfsWorkspace $/TeamProjectA/Main/.../Tools/git-tf C:\_git-tf_
tf get /recursive C:\_git-tf_

C:\_git-tf_\git-tf.exe clone http://yourServer:8080/tfs/yourCollection $/TeamProjectA/Main C:\Workspaces\Main

tf workfold /unmap /workspace:tfsWorkspace $/TeamProjectA/Main/.../Tools/git-tf
tf workspace /delete /collection:http://yourServer:8080/tfs/yourCollection tfsWorkspace
rd /S /Q C:\_git-tf_
Not so elegant, but might work for you.

Sincerely yours ,
Alex
Mar 19, 2013 at 1:06 AM
Thank you for all the replies.
Since I already have code in TFS and just need to create a workflow for devs to download and properly configure TFS and git-tf and git, I didn't go back trying to figure out cause of the issue. I've used script suggested by arukhlin and that worked well.
Team will use script to clone and configure TFS and git-tf.
That is exactly what I wanted.

Thank you.