1

Apparently Git is suppose to open an editor for you when it wants you to enter a commit message. This never happens on my machine so I am wondering if it is just not set up or I don't have Vim or something. TextEdit is my default text editing (.txt) application.

How can I have Git open a text editor for me to use?

KingCrunch
  • 128,817
  • 21
  • 151
  • 173
Kevin_TA
  • 4,575
  • 13
  • 48
  • 77

2 Answers2

2

See man git-var for explanation on how git finds an editor to start:

The order of preference is the $GIT_EDITOR environment variable, then core.editor configuration, then $VISUAL, then $EDITOR, and then the default chosen at compile time, which is usually vi

I'd start with export GIT_EDITOR=/path/to/your/editor or git config --add core.editor /path/to/your/editor, to provide an editor which you know to be installed.

Koraktor
  • 41,357
  • 10
  • 69
  • 99
Anton Kovalenko
  • 20,999
  • 2
  • 37
  • 69
0

To use Nano as the inline terminal editor (I'm on a Mac)

git config --global core.editor "nano"

To use the Sublime Text Mac app

First add the path to the Mac App Sublime Text.app (where the bin subl is located) to your profile: echo 'export PATH="/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"' >> ~/.zprofile

Test it by opening a new terminal then running subl in the terminal, the Sublime Text app should open.

Add subl as your preferred text editor to your git profile

git config --global core.editor "subl -n -w"

Test it to make sure Sublime opens it and do a small edit, save

git commit --amend

View the change

git log --oneline

(Close and re-open the terminal if you are using Visual Studio Code with the embedded terminal)