SourceTree is my go-to Windows git client. It has pretty good UI and exposes
most of the more advanced features that I need (
git add -p being chief among
But I still spend a lot of time in the command line via Cygwin and want the ability to open SourceTree to whatever repo I happen to be in at the time.
I don’t like the manual process of loading up SourceTree and adding a new repository bookmark. A lot of times, I don’t even care to book mark the repo: I just want to pull it up and look at some diffs or quickly add parts of a file.
Luckily, SourceTree added a few command line arguments a few versions back that allow you to open it right to a repository.
It’s a little clunky in cygwin, like most things, but with a small script it becomes very accessible.
There’s a couple of tricks involved
cygpath -wato convert the Unix file paths for the directory to the absolute windows path. So
- Override the
$HOMEenvironment variable. Cygwin will be default pass the full windows path to
~as the new
HOMEenvironment variable to Source Tree. This caused problems for me when SourceTree in turn shelled out to git and git complained about the
.gitconfig. I fixed it by making sure SourceTree used