Git-tfs : Use of Git with a TFS server

(or how to use Git in unfriendly environment!)

1. Clone main branch of the TFS repository

At the Visual Studio first opening, choose to deconnect temporary the solution from the server (otherwise it will modify some files)

2. Synchronise with the Tfs repository

2.1. Fetch the commits from the trunc

git tfs fetch

2.2. Commit to the Tfs repository

2.2.1 Commit manualy
git tfs ct

! Always do a fetch & rebase (or a merge) before the commit (to avoid a overwrite of a file by your modifications)

2.2.2 Commit automaticly some local Git commits
git tfs rcheckin

Note : During the use of rcheckin, you can add references, in your local commit message, to Tfs workitems to associate or close them ( during the commits on the TFS Server).
The synthaxe is the following :
git-tfs-work-item: <id> associate
git-tfs-work-item: <id> resolve

3. Manage a Tfs branch

3.1. Fetch the Tfs branch

Since the version 0.16 of git-tfs where my work was merged, you could easily fetch a TFS branch with the command :

git tfs init-branch $/MyProject/BrancheName

3.2. Fetch new commits from the Tfs branch

git tfs fetch -i myTfsBranch

3.3. Commit on the Tfs branch

git tfs ct -i myTfsBranch

4. Sources

http://www.drrandom.org/post/2011/11/16/Grappling-with-multiple-remotes-in-git-tfs.aspx
http://stackoverflow.com/questions/8559814/merge-two-tfs-branches-with-git-tfs

Report des changeset d’un depot git vers tfs:
https://groups.google.com/group/git-tfs-dev/browse_thread/thread/929d005ff9cdcc23
http://www.tigraine.at/2010/09/01/using-git-from-powershell-just-got-easier-posh-git/

https://github.com/git-tfs/git-tfs/issues/171
https://github.com/git-tfs/git-tfs/issues/172
https://github.com/spdr870/gitextensions/issues/869

Philippe Miossec 01 June 2012
blog comments powered by Disqus