git-open supports Visual Studio Team Services

December 6, 2017

I'm really excited that git-open 2.0 was just released. This newest version of git-open includes some changes that I contributed to support for Visual Studio Team Services and Team Foundation Server.

git-open already had great support for GitHub, so I was already using it for my open source projects. It also supports BitBucket and GitLab. But I wanted to use it for my day job, where all my repositories are hosted in VSTS.

What is git-open?

git-open is a nifty tool that will let you run a command on the command-line, git open, to open up a web browser to your Git repository hosting provider. This means that I can run a single command, right from within my Git repository, and it will open up a browser and navigate to my project in Visual Studio Team Services.

git-open

This is amazing because as much as I try to hang out in the command-line, that's not always useful for large projects. If I'm hacking on my (comparatively) little open source project, libgit2, it's easy enough to use ctags or to grep over the whole codebase. But for a big project that's not so easy.

What I really want is to use the great Roslyn-powered code search functionality in VSTS. So now I can open up a new browser pointing at VSTS without having to click around to get a new browser window open.

It will even look at the current branch that you're on and navigate there in the browser interface. This is perfect if you're starting your branch workflow by creating a new branch from a VSTS work item.

Create Branch from Work Item

When I start my branch workflow this way, I've always got a branch on the server that I fetch to my client. And then I can push my changes back and eventually open a pull request. And git open supports this workflow beautifully, it will look at the branch that I have checked out locally and try to navigate me there in the web browser. It can navigate to branches in Git repositories hosted in several hosting providers, including VSTS and TFS.

But it's not just branches - it can also navigate to the work item hub. This gives you a complete end-to-end branch workflow: create a new branch from a work item in VSTS, pull it down, and then you can use git open --issue to navigate back to the VSTS work items in your browser.

git open --issue

Getting Started

To get started with git-open, all you have to do is download the latest release, unzip it and then put the git-open shell script somewhere in your path.

git has an extension model where all the commands you run - say git pull - are actually separate commands. They're not all just built in to the git command itself. When you run git pull, git goes looking for an executable in your path named git-pull.

So if you want to add your own Git commands, you can just put an executable named git-something into your path. When you run git something, Git will find your git-something executable.

Tip
I have a directory in my home directory where I put useful shell scripts that I make sure is included in my path. On Unix systems this is ~/bin. On Windows machines, this is %HOMEPATH%/bin.

Pro-Tip
I also manage all these scripts - along with my dotfiles - in a Git repository. So when I start working on a new machine, I can just git clone my dotfiles repository.