'How do I set up my terminal on Mac to auto open Sublime Text Editor when using git commit command?

I am trying to set up git on my terminal, and need it to open up Sublime text when I use a git commit command, so that I can add a note to my commits. If I type "subl" sublime opens up fine, however when I type git commit the following error message comes up

hint: Waiting for your editor to close the file... '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl' -n -w: /Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl: No such file or directory error: There was a problem with the editor ''/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl' -n -w'. Please supply the message using either -m or -F option.

I have been following a Udacity git and github course which explains set up.

I am wanting sumblime text editor to open so I can type a note for my commits. However instead it is asking that I use -m to type a note which isn't always going to be convenient.



Solution 1:[1]

You have to set up sublime text 3 as your default editor through the terminal.

run this: git config --global core.editor "subl -n -w"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user288558