'How to open Sublime Text 3 editor with git commit

I have already configured Sublime Text 3 as my text editor for git Bash. Sublime successfully opens when I type subl 'filePath'

However, when I try a git commit, the text editor fails to open and outputs the following error:

hint: Waiting for your editor to close the file... 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.

I have added to files to the staging area and am ready to commit.



Solution 1:[1]

You can try this

You can set your default editor in Git to use Sublime Text 3.

  1. Install Sublime Text 3.

  2. Open Git Bash.

  3. Type this command:

git config --global core.editor "'C:/Program Files (x86)/sublime text 3/subl.exe' -w"

Solution 2:[2]

I used the below command on Mac and it worked

$ git config --global core.editor "'/Applications/Sublime Text.app/Contents/SharedSupport/bin/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 Tony Ngo
Solution 2 Devrath