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.

  • Versioning Mysql Data (Not Just Schema)
  • git bisect doesn't work, no output
  • Error after removing submodule: The following path is ignored by one of your .gitignore files:
  • How to delete something that was accidentally pushed
  • Undo Git Stash Pop
  • .gitignore not working in github for mac program
  • 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

  • How to revert a folder to a particular commit by creating a patch
  • Keep commits history after a 'git merge'
  • .gitignore for PhoneGap/Cordova 3.0 projects - what should I commit?
  • git deploy with submodules
  • Unable to run git diff on a file that has moved
  • Find latest git tag from the remote git repository
  • 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.