shortcut to Sourcetree in Mac OS Finder

Is there an easy way to add a link to the Mac OS Finder toolbar that will open up SourceTree for the current folder (if it contains a git repo)? I've done this with Textmate and the terminal (shown below). The addition of a git GUI would complete the trifecta!

4 answers

It's simple to make an application with applescript and drop it to the finder toolbar.

on run
	tell application "Finder"
		set theFolder to (the folder of the front window as alias)
		if (exists folder ".git" of theFolder) then
			tell application "SourceTree"
				activate
				open theFolder
			end tell
		end if
	end tell
end run

But every time you get a "want to add to root" question.

Are there commandline options for SourceTree to just open a git folder?

The 'stree' command line tool will open the current directory or any paths it is given on the command line. You can install it using the menu option 'SourceTree > Install Command Line Tools' on the direct download version of SourceTree, or get the supplemental binary for the App Store version from here http://downloads.atlassian.com/software/sourcetree/SourceTreeAppStoreCmdLineToolInstaller.pkg

The command-line version:

on run
	tell application "Finder"
		set theFolder to (the folder of the front window as alias)
		if (exists folder ".git" of theFolder) then
			set theFolder to quoted form of POSIX path of (the folder of the front window as alias)
			do shell script "screen -dmS sourcetree-droplet bash -c \"cd " & theFolder & "; /usr/local/bin/stree\""
		end if
	end tell
end run

This still opens "Create Bookmarks?" window.

The command-line version:

on run
	tell application "Finder"
		set theFolder to (the folder of the front window as alias)
		if (exists folder ".git" of theFolder) then
			set theFolder to quoted form of POSIX path of (the folder of the front window as alias)
			do shell script "screen -dmS sourcetree-droplet bash -c \"cd " & theFolder & "; /usr/local/bin/stree\""
		end if
	end tell
end run

This still opens "Create Bookmarks?" window.

The command-line version:
on run
	tell application "Finder"
		set theFolder to (the folder of the front window as alias)
		if (exists folder ".git" of theFolder) then
			set theFolder to quoted form of POSIX path of (the folder of the front window as alias)
			do shell script "screen -dmS sourcetree-droplet bash -c \"cd " & theFolder & "; /usr/local/bin/stree\""
		end if
	end tell
end run

This still opens "Create Bookmarks?" window.

If you don't have a bookmark for the opened repo then yes, you'll get an option to create a bookmark.

I would like to know this too...

GitX has one, maybe get the sourecode here to build one for SourceTree:

http://code.google.com/p/git-osx-installer/wiki/OpenInGitX

I would like to know this too...

GitX has one, maybe get the sourecode there to build one for SourceTree.

http://code.google.com/p/git-osx-installer/wiki/OpenInGitX

In 1.3 if you right-click a folder in Finder and go to 'Services' there is an option 'Open In SourceTree'.

True, but three clicks are needed, droplet only one.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

573 views 1 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you