Blog

Maintaining Your SourceTree Bookmarks Throughout Several Machines

     
By on May 11, 2016 - 3 Minutes

If you use Git, you’ve probably heard about SourceTree. This superb Git client from Atlassian, solves 99% of your day-to-day Git needs. It connects to both Github and Bitbucket and has apps for Mac and Windows. On top of that, it’s free (as in beer free).

Syncing SourceTree between computers

I currently use SourceTree in two machines, my iMac and my trusty old non-retina-still-has-a-dvd-slot MacBook Pro. I sync my work and personal folders using Syncthing, a free solution which also avoids cloud-centered solutions like Dropbox, Box, etc. All my repos are in the exact same location in the file system and I use the same account name in both machines. This is important as SourceTree bookmarked repos are stored as absolute locations, they are a path from the root of your file system, e.g:
/Users/dfreniche/Sync/MobileJazz/MyNextBeautifulProject

I wanted to have the same bookmarks in both machines, surely it can’t be difficult, right? Well, SourceTree does not have this option right out of the box, but I found where the config file is, and started experimenting.

All bookmark configs are stored in (OS X) ~/Library/Application Support/SourceTree inside a file called browser.plist. This file is compiled in binary format, but will be familiar to any iOS/OS X developer out there. If you’re a little unsure, a PList is a property list file which contains a bunch of key/values stored in an XML format.

browser.plist in OSX
Inspecting the contents of browser.plist with Xcode. Just write “open browser.plist” in your Terminal

You can view and manipulate these files from Terminal.

This line will print the contents of your SourceTree bookmarks property list file, in an XML-formatted output.

Now that I had located this file, I thought this was going to to be easy. Initially I tried to create a symbolic link:

This created a file called browser.plist which pointed to the real file inside my Dropbox folder: /Users/dfreniche/Dropbox/shared_config/sourcetree/

lt needed the source, real file, destination and the name of the fake file: the symbolic link.

I’ve used symlinks since I first discovered them in ‘95. They behave as they are the original file, however the actual file can be elsewhere: in another directory, file system, partition or even another computer via NFS.

But unfortunately this didn’t work: SourceTree recreates the browser.plist file, it deletes your nice symbolic link and writes a file on top. I tried hard links (without the -s) but still couldn’t get it working!

So I ended up using two alias, which you can copy in your .bash_profile:

Now, each time I change something in my SourceTree Bookmarks, I just need to do:

…and when I go back to my other computer, as Dropbox has already synced the browser.plist file, I just can do:

Read the comments
Diego Freniche
Writing bugs since 88 (BASIC), one at a time. Retro computer user, gaming lover and internationally renowned snake-oil seller at conferences. My CV is up on GitHub forcing recruiters to clone.

Want to receive more insightful articles like this? Subscribe here.


By submitting your information you agree to our Privacy Policy