Using Sublime Text to write your git commit messages
Here’s another blog post about setting up a dev environment. (I’m using OSX 10.10.)
git config --global core.editor "subl -n -w"
But wait! What if our subl
symlink isn't set up for whatever reason?
First, I tried:
git config --global core.editor "open -a 'Sublime Text.app'"
..but quickly ran into an error whenever I ran git commit
: "Aborting commit due to empty commit message."
Realizing that I needed to still add the -n
and -w
tags, I instead tried:
git config --global core.editor "open -W -n -a 'Sublime Text.app'"
..which didn't work very well. I thought the open
command's -W
and -n
flags would work just like the -n -w
flags for Sublime Text, but that just wasn't the case. I got similar, but very wonky behavior compared to what I was expecting. After poking around the documentation for the open
command further, I found out I could send arguments directly to the application.
For my final (successful) attempt, I used:
git config --global core.editor "open -a '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' --args -n -w
"
This works for Sublime Text 3 and throws in the -n -w
tags directly to the application via the --args
tag. This is essentially equivalent to the subl -n -w
that GitHub suggests, without setting up a symlink.
Lessons learned: Symlinks are awesome and not using them makes your life difficult because the
open
command does weird stuff.