How do I open a repository in SourceTree from the commandline (CLI) ?

Ivar Vasara
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 1, 2011

Is there a simplified command that I can use to open a directory/repo in SourceTree ?

6 answers

1 accepted

18 votes
Answer accepted
Michael Rabbitt
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 13, 2011

I've been using this:

open -a SourceTree /path/to/repo

It's better than nothing. You could make a bash alias for it--put this in your ~/.bash_profile:

alias sourcetree='open -a SourceTree'
Then you can do:
sourcetree /path/to/repo

Ralph Callaway
Contributor
December 17, 2014

this is simpler than that now, just install the command line tools and then run `stree /path/to/repo`

Like brettz9 likes this
ByteR June 4, 2015

I'd like to directly open a commit (just like the "Jump to:" > "Commit..." menu). Is that possible somehow?

Pratyush Tewari
Contributor
October 24, 2019

We do not have admin access on our computers so we cannot install the command line tools.

alias sourcetree='open -a SourceTree'

and

sourcetree /path/to/repo

yet it opens only the repository browser and not the actual repository in the sourcetree.

Is there any Solution?

I also tried running

/Applications/Sourcetree.app/Contents/Resources/stree /path/to/repo

and I got the same results.

5 votes
Ralph Callaway
Contributor
December 17, 2014

Just install the command line tools, then you can do

 

stree /path/to/repo

It'll open the repo in source tree and ask if you want to create a bookmark for it

Tirthankar Bhowmick
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 26, 2019

It is not working anymore, any idea? Sourcetree v3.0 on Mac. Ignores the argument of directory and opens SourceTree repository window.

Like glynnormington likes this
2 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2011

Oops, I only read the description, I see you meant the Command-line, sorry.

Please see this issue: https://jira.atlassian.com/browse/SRCTREE-385

Ivar Vasara
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 1, 2011

That issue captures my request exactly - I've added comments in the feature request.

I won't close this question until the feature's implemented though :)

0 votes
Glyn Normington February 5, 2012

Thanks Steve. Worked a treat. Any chance of documenting this in the release notes for others' benefit?

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2012

Ah yes, it was in the release blog but not the notes, I'll add the link.

0 votes
Glyn Normington February 5, 2012

I installed SourceTree 1.3.0 from the Mac OS App Store, but I can't find the "SourceTree->Install Command Line Tools" menu item mentioned in the release notes. (And BTW, the release notes claim that 1.3.1 is available in the App Store, which doesn't appear to be the case.)

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2012

Unfortunately the App Store rules don't allow installers so we couldn't include it. You can, however get a standalone installer here: http://downloads.atlassian.com/software/sourcetree/SourceTreeAppStoreCmdLineToolInstaller.pkg

The release notes are just relaying the fact that 1.3.1 in the App Store includes all the changes from 1.3.1.1. Unfortunately Apple haven't approved the update yet, but we've submitted it.

0 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2011

[edit]please see the next answer regarding the command line - I'll leave this here anyway since it might be interesting to someone[/edit]

There are several ways:

  1. Drag & drop the repo folder from finder, either onto a place in the Bookmarks tree, or just on to the dock icon
  2. File > Open or Cmd-O
  3. There's also the 'Open Recent' menu, the contents of which also appear in Mission Control in Lion and on the dock right-click menu

Cheers

Steve

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events