0

I'm learning how to use the Ubuntu CLI on Windows for executing things like git commands, and so far everything works smoothly. My only gripe however is that whenever an instance of ST3 opens for commit messages, a second tab opens and somewhat ruins the flow of things.

Originally, what I had done to set ST3 as the text editor was append the following line to the .gitconfig file:

[core]
    editor = /mnt/c/Program\\ Files/Sublime\\ Text\\ 3/subl.exe `wslpath.sh -w $PWD/.git/COMMIT_EDITMSG` -nw

Note: "wslpath.sh -w" works like cygpath, for those familiar with Cygwin functions, in that it converts Unix formatted directories to work with Windows.

I want to prevent this additional tab from opening every time I commit a change, and only have the window for editing messages appear:

screenshot of editor

andrybak
  • 2,129
  • 2
  • 20
  • 40
Dom
  • 1
  • 1
  • Does the number of tabs go up by one for every commit you make or is it always two no matter what? – OdatNurd Mar 17 '18 at 22:34
  • 1
    Possible duplicate of [How can I make Sublime Text the default editor for Git?](https://stackoverflow.com/questions/8951275/how-can-i-make-sublime-text-the-default-editor-for-git) – andrybak Mar 17 '18 at 23:03

1 Answers1

0

You're not supposed to add the path of the file to the command. Git will put it as an argument for the command on its own.

So `wslpath.sh -w $PWD/.git/COMMIT_EDITMSG` should not be part of the command set as core.editor.

Your command relies on opening file COMMIT_EDITMSG, which would not work correctly when git will try to open file for editing of a merge commit message, or interactive rebase todo file, or editing an annotated tag message, etc. The commit message is not the only place where editing is done through a file.

The additional tab (as in the screenshot) then seems to be coming from the fact that the file is actually listed in the resulting command two times: once from core.editor config variable and a second time by git commit.

andrybak
  • 2,129
  • 2
  • 20
  • 40
  • The commit windows would not work at all if not for that line. It changes the directory formatting from linux to windows. I guess that's what I get for trying to use Linux subsystem. Probably switching to Powershell. – Dom Mar 23 '18 at 22:37