Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGary Ford
14,475 PointsSublime Text 2 as default editor in Git
How do I set up Sublime Text 2 as my default editor in Git?
5 Answers
Chris Dziewa
17,781 PointsCheck out this link for Changing git editor to Sublime. This is assuming you are using a mac.
Tom Coakes
3,695 PointsGary, could it be the fact that you have spaces in your path? Does it work if you instead type:
ln -s "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
Gary Ford
14,475 PointsAfter attempting to set Sublime Text as my default using this command with no success:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
i decided to try nano following the instructions in notes for the video. I was able to create the README but then had trouble with the commit. Below is the code from the Terminal. Sorry it’s so long but I didn’t want to leave anything out. Hopefully I haven’t messed up things too much. I don’t know how to fix this. It seems there is a conflict between sublime and nano:
Macintosh-2:my_really_cool_project gfinchitown$ export EDITOR=nano Macintosh-2:my_really_cool_project gfinchitown$ nano README Macintosh-2:my_really_cool_project gfinchitown$ git add README Macintosh-2:my_really_cool_project gfinchitown$ git commit subl -n -w: subl: command not found error: There was a problem with the editor 'subl -n -w'. Please supply the message using either -m or -F option. Macintosh-2:my_really_cool_project gfinchitown$ git commit subl -n -w: subl: command not found error: There was a problem with the editor 'subl -n -w'. Please supply the message using either -m or -F option. Macintosh-2:my_really_cool_project gfinchitown$ git commit subl -n -w: subl: command not found error: There was a problem with the editor 'subl -n -w'. Please supply the message using either -m or -F option. Macintosh-2:my_really_cool_project gfinchitown$ git commit -m error: switch `m' requires a value usage: git commit [options] [--] <pathspec>...
-q, --quiet suppress summary after successful commit
-v, --verbose show diff in commit message template
Commit message options -F, --file <file> read message from file --author <author> override author for commit --date <date> override date for commit -m, --message <message> commit message -c, --reedit-message <commit> reuse and edit message from specified commit -C, --reuse-message <commit> reuse message from specified commit --fixup <commit> use autosquash formatted message to fixup specified commit --squash <commit> use autosquash formatted message to squash specified commit --reset-author the commit is authored by me now (used with -C/-c/--amend) -s, --signoff add Signed-off-by: -t, --template <file> use specified template file -e, --edit force edit of commit --cleanup <default> how to strip spaces and #comments from message --status include status in commit message template -S, --gpg-sign[=<key id>] GPG sign commit Macintosh-2:my_really_cool_project gfinchitown$
Any idea how to resolve this and get my system back to before I attempted to set up sublime as the default editor?
Chris Dziewa
17,781 PointsAll it did was not allow you to commit because what you passed in after wasn't what was expected. All you have to do is type git commit
and it should automatically open a text editor. I personally don't even use an editor to type commit messages. To do it this way you can just type git commit -m "Your commit message here"
Gary Ford
14,475 PointsChris: I received and email from Tommy (the instructor) on how to reconfigure git to use nano, which I will try today. Per your earlier message, I agree with the frustration making you a better coder. Not about to give up now. lol Curious, what do you personally use to type commit messages? Thanks again for your help. It's much appreciated!
Chris Dziewa
17,781 PointsI type right in the Terminal window on the command line. It's much faster and since commit messages are best left short and concise I don't have to worry about having extra editing capabilities.
Alexandra Spalato
11,478 Pointsi use iterm, and have found the configuration here: http://devsnaps.herokuapp.com/blog/2013/11/09/setting-up-the-terminal-for-development-in-os-x there's a plugin to have sublime text, i config it yesterday, and as i really begin with console and git yesterday, if i did everybody can! for the theme terminal i have choosen ys. when all is install, to open a file with sublime type file_name subl (and not sublime) i've tryed to have sublime as default editor doing that: git config --global core.editor "subl -n -w" ... but don't work :-( so i i add nano as default : git config --global core.editor nano
Hope its helps!
Chris Dziewa
17,781 PointsChris Dziewa
17,781 PointsOtherwise for windows try this answer on Stack Overflow.
Gary Ford
14,475 PointsGary Ford
14,475 PointsThanks Chris. I am on a Mac. I entered the symlink: ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl command but am getting the following error: No such file or directory. I'm wondering if I should just use nano as is being used in the video since I will only be using nano for commits and README files. What are your thoughts?
Chris Dziewa
17,781 PointsChris Dziewa
17,781 PointsMaybe you could check in your applications folder to see if that is the correct path to the folder. You might have to right click on the app where you can select view package contents. That is strange it isn't showing up. As for which one is better it is a matter of personal preference. Nano is nice in that it opens right in the Terminal but editing isn't as user-friendly. If I were you I would try everything I could to at least get the terminal command configured for Sublime.
subl -n .
is one of my most common commands-used to open folders in Sublime for any project.Gary Ford
14,475 PointsGary Ford
14,475 PointsI appreciate your help. I think I've really messed things up in Terminal. I've sent an email to the instructor and hopefully he'll be able to help me undo what I have done. At this point I think I may just start using a GUI interface. I hope I didn't create permanent problems. Sooo frustrated....
Chris Dziewa
17,781 PointsChris Dziewa
17,781 PointsWhat happened? I have had plenty of those days. I'm starting to think that frustration is a prerequisite to becoming a better programmer. Don't worry, you probably didn't do anything too terrible.