Search code examples
gitcommand-lineatlassian-sourcetree

How do you open SourceTree from the command line?


Is there a quick and easy way to open a git repository in SourceTree from the command line?

I do a lot of git work from Terminal, but sometimes there's no replacement for a good history view/diff. Would love to be able to open without using bookmarks.


Solution

  • Installing the SourceTree Command Line Tools will provide you with the stree command. This will allow you to open the current directory in SourceTree.

    sourcetree commandline tools

    You can also specify a particular path to a repo

    stree ~/my-repo-in-another-folder
    

    If installing command-line tools isn't an option for whatever reason, you can also do the following:

    open -a SourceTree path-to-file
    

    and maybe set up an alias in .bashrc or .zshrc

    alias sourcetree='open -a SourceTree'
    

    For those who are using SourceTree 3

    alias sourcetree='open -a SourceTree\ 3'