Working with TFS and Git

Steph Locke



Build StatusCoverage Status

This package allows you to work with Visual Studio Team Services (VSTS) and Team Foundation Server (TFS). The original version(s) of the package were solely aimed creating git repositories but with the ability to create Projects and more, [@velincw]( to be a little bit more ambitious! This will be a complete rebuild, with some aliases provided for backwards compatability.

The package will probably stop where it used to - at git source control functionality as git2r and other packages handle this.

Install tfsR

if (!require(devtools)) install.packages("devtools")
devtools::install_github("stephlocke/tfsR", build_vignettes = TRUE)

Old content


You must have a username (often an email address or AD account) and password for connecting. That’s basically it!

NB - you can now use public acces tokens.

Intended use

Since you need to provide credentials to these functions, it is anticipated that you would use these on an ad-hoc basis in much the same way you would use devtools.

It’s a great way to quickly setup a repository if you need to get your stuff into source control.

In terms of actually using your repositories once they’re created, I recommend git2r.


Using tfsR

Get info on existing repositories

A great place to start is a) verifying you can connect to your TFS and b) see what projects you could create repositories under


authcreds<- TFSAuth(pwd="fz43enydh7vi2o6jqir2gmftohh7ooz2lizqvy6jxtw4ltrpwola")

repositories <-getTFSProjects(tfs,authcreds)


Create a new repository

TFS doesn’t allow you to create new projects so if you want to create a new repository, you have to do it in an existing project or go to the GUI and manually create one (there is no API call for this).

You don’t want to start nesting repositories so you need to make the repository under a top-level project. As such, in this bit of functionality, you provide the name of the top-level project which you want to put your repository, and it goes away and gets a GUID if the project exists and is a top-level project, then tells the API to create a repository in it.

authcreds<- TFSAuth(pwd="fz43enydh7vi2o6jqir2gmftohh7ooz2lizqvy6jxtw4ltrpwola")

parentproj   <-"tfsr3"
newrepo      <- as.character(random::randomStrings(n=1, len=6))
createdrepo  <- createTFSRepository(tfs,authcreds,parentproj,newrepo)

This will provide you with the URL you need to be able to push and pull commits to. In this case it has created a repository called “newrepo” which can be interacted with at the URL createdrepo

Delete a repository


You can delete a repository programmatically if you so choose. Primarily, I wrote the method to keep these vignettes clean!

Let’s clean up the repo we just made.