Skip to content

Instantly share code, notes, and snippets.

@rpattabi
Created September 24, 2012 15:39
Show Gist options
  • Save rpattabi/3776582 to your computer and use it in GitHub Desktop.
Save rpattabi/3776582 to your computer and use it in GitHub Desktop.
Using git to work with TFS

Introduction

There is an excellent adapter for git <--> tfs interaction. It is called git-tfs. Using this I could use my favorite git efficiently. Once I am done with my work I could push to tfs. This gist explains the steps I followed and brief git tfs command reference.

Installation

Run the below as Admin

C:\> @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin

C:\> cinst GitTfs  # this takes a lot of time. at some point one dialog box is displayed and 
                   # all the applications are closed. But it gets completed.

Workflow

Whenever there is an interaction with tfs, instead of using usual git commands like git pull, use git tfs commands.

cloning tfs repository

D:\> git tfs quick-clone http://inspexes3atsrv:8080/tfs/defaultcollection $/GUIATPs/SmartUITest
  • quick-clone doesn't pull the whole list of history. it should be enough.
  • if we make quick-clone to clone, it takes forever. but it does the job.
  • if for some reason it fails (e.g. connectivity to tfs is lost), we have to clean up the directory and try again from the beginning.

pull

Don't use git pull. instead...

git tfs pull

usual git

Following things work as usual

git log
git status

git add .
git commit -a -m 'commit to local'

git branch
git branch -r # note the remote branch is not called as origin/master. it is tfs/default.

git diff tfs/default master

commit to tfs

Quick way to checkin, but can't specify additional info such as code reviewer

git tfs checkin -m 'Did stuff'

If you prefer to checkin with the usual tfs checkin dialog (which also provides options such as diffing the files, addressing conflicts, adding code reviewer, etc)

git tfs checkintool

shelve

git tfs shelve A_SHELVESET_NAME
git tfs shelve-list
git tfs unshelve A_SHELVESET_NAME

References

Introduction

There is an excellent adapter for git <--> tfs interaction. It is called git-tfs. Using this I could use my favorite git efficiently. Once I am done with my work I could push to tfs. This gist explains the steps I followed and brief git tfs command reference.

Installation

Run the below as Admin

C:\> @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin

C:\> cinst GitTfs  # this takes a lot of time. at some point one dialog box is displayed and 
                   # all the applications are closed. But it gets completed.

Workflow

cloning tfs repository

D:\> git tfs quick-clone http://inspexes3atsrv:8080/tfs/defaultcollection $/GUIATPs/SmartUITest
  • quick-clone doesn't pull the whole list of history. it should be enough.
  • if we make quick-clone to clone, it takes forever. but it does the job.
  • if for some reason it fails (e.g. connectivity to tfs is lost), we have to clean up the directory and try again from the beginning.

pull

Don't use git pull. instead...

git tfs pull

usual git

Following things work as usual

git log
git status

git add .
git commit -a -m 'commit to local'

git branch
git branch -r # note the remote branch is not called as origin/master. it is tfs/default.

git diff tfs/default master

commit to tfs

Quick way to checkin, but can't specify additional info such as code reviewer

git tfs checkin -m 'Did stuff'

If you prefer to checkin with the usual tfs checkin dialog (which also provides options such as diffing the files, addressing conflicts, adding code reviewer, etc)

git tfs checkintool

shelve

git tfs shelve A_SHELVESET_NAME
git tfs shelve-list
git tfs unshelve A_SHELVESET_NAME

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment