3

Everytime when I am merging dev branch with my local branch I get the following error:

subl -n -w: subl: command not found
error: There was a problem with the editor 'subl -n -w'.
Not committing merge; use 'git commit' to complete the merge

I am getting this error even when Sublime Text is closed however I am not sure if it's complaining about Sublime. Does anyone know how to avoid or fix this error?

brunodd
  • 2,474
  • 10
  • 43
  • 66
  • 1
    Do you have sublime defined as the editor in a config file? Does it use a full path to the `subl` binary? – pjmorse Jul 02 '15 at 13:44
  • Ran into this problem on windows and solved it by specifying the full path to `subl` (which is **not** the same as sublime; it's a different executable). –  Jul 02 '15 at 15:10
  • @torazaburo and how dod you do that? – brunodd Jul 03 '15 at 08:23

3 Answers3

2

Your git editor has not configured properly.You have to give full path while configuring your git editor.

For Sublime text 3 use following command-

git config --global core.editor " 'C:/Program Files/Sublime Text 3/subl' -n -w"

If you have Sublime text 2 use following command-

git config --global core.editor " 'C:/program files/sublime text2/sublime_text.exe' -n -w" 
Garry
  • 4,493
  • 3
  • 28
  • 48
Roshan shetty
  • 66
  • 1
  • 7
2

Old question, but I thought I would pitch in for future readers. The above answers are valid, but dont explain what is going on.

When you run the git commit or git merge commands, git tries to find the text editor that is configured in the .bash_profile on a mac (or its windows equivalent), and tries to open the editor so that the user can enter a message associated with the commit. When it tries to open the text editor and cant find it, it throws the error. There are two ways to resolve this error:

  • Check the path to the "alias" or the core editor and amend as per the instructions above.
  • Alternatively, you will be able to accomplish your commit by using the -m option. Eg. git commit -m "YOUR_COMMIT_MESSAGE_HERE", thereby bypassing the need to open the text editor to enter the commit message.
tirupats
  • 158
  • 1
  • 10
-1

To find if its tool specific issue... Run following command to see the merge tool configured (command shows all the configuration settings, check in out put something like merge.tool=xyz...)

git config --list

Seems the tool is not accessible to git. You can try setting different tool or fix the path etc. Use the following command to set new tool

git config --global merge.tool <newtoolvalue>

(system wide and user specific settings are stored in file /etc/gitconfig and /usr/home/.gitconfig resepctively. i.e when you use the option either --global or --system.) You can use git config --global --unset <optionname> to unset the value.

Nitin
  • 326
  • 4
  • 11
  • 1
    This doesn't address the thrust of the question which is configuring `subl` to work properly. –  Jul 02 '15 at 15:11