Sync TFS and GIT

Today we have all our source code on our local TFS server. Now we want that some external parties can access a portion of the code. We therefore looking at the possibility that e.g. Clone this code to an external GIT server they can access.

I have looked at the gittfs. But if I understand correctly, you have to manually synchronize GIT and TFS when it happened changes on any of them. Is there a way to have a clone of the code that is automatically synced.

If there are changes in TFS, it is automatically synced to GIT, and vice versa. There should be no uncertainty if I work with the most current code

  • Branching Refresh in Visual Studio in TFS Online using Git
  • Integrate TFS git source control and JIRA
  • Howto query TFS 2013 API for git repositories in a TeamProjectCollection?
  • How to setup TFS 2013 build definition to build from Git tag?
  • linux git authentication to TFS git repo
  • Does TFS 2013 have shelvesets anymore (when using GIT)?
  • TFS 2013.4 build with GIT submodules are failing
  • Visual Studio git clone always use LF for a file
  • One Solution collect form web for “Sync TFS and GIT”

    There is no way to sync 2 repositories evolving separatly 100% automaticaly with whatever solution you choose. You will always have conflicts that you should merge manualy. You could find a workflow that will prevent most of them but never solve all the cases and this cases will be difficult to solve…

    Anyway, you could nerly achived what you want (it depends of your expectations : do you need branching support –hard–,…) with git-tfs (I have included in git-tfs all needed to do that but never used in production) but it’s a little bit tricky.

    You need to clone your TFS repository in a bare repository :

    git tfs clone https://server/tfs/TeamCollection $/project/trunk --bare --with-branches

    then you need to write in your post-receive hook of this bare repository something like that (I do not remember if it works) :

    branch=$(git rev-parse --symbolic --abbrev-ref $1)
    if [ "master" == "$branch" ]; then
        branch="default" 
    fi
    git tfs rcheckin --bare -i $branch
    

    With that, every time someone push in the git repository, the commits will be checked in in TFS.

    For more comfort (otherwise they will always have boring conflicts to solve when they try to push), you could sync git repository with TFS server with a scheduled task with the command (this way they will be aware of new commits sooner) :

    git tfs fetch --all
    

    Note : I don’t remember if this command could be used in a bare repository (now that I think about that, I don’t think so). Otherwise you will have to use instead git tfs fetch -b=myGitBranch -i tfsRemote for each existing branch 🙁

    But I’m sure they will never be able to work with branches that was not already created in tfs 🙁
    And some other stuff could be difficult or impossible to do…

    I hope it will help.

    PS : that’s a hard job you are trying to do for someone not used to git-tfs…

    Git Baby is a git and github fan, let's start git clone.