How do I globally configure git to use a particular editor (e.g. vim
) for commit messages?

- 24,552
- 19
- 101
- 135

- 76,030
- 23
- 64
- 76
-
259"How to get git to go to vim for commit comments from the git-go?" – Michael Burr Apr 08 '10 at 00:34
-
4Related (possible duplicate): [How can I set up an editor to work with Git on Windows?](https://stackoverflow.com/q/10564/3357935) – Stevoisiak Aug 17 '17 at 15:45
-
5What's wrong with EMACS (smile) ? – Shawn Eary Jul 01 '21 at 15:06
34 Answers
Setting the default editor for Git
Pick one:
Set
core.editor
in your Git config:git config --global core.editor "vim"
Set the
GIT_EDITOR
environment variable:export GIT_EDITOR=vim
Setting the default editor for all programs
Set the standardized VISUAL
and EDITOR
environment variables*:
export VISUAL=vim
export EDITOR="$VISUAL"
NOTE: Setting both is not necessarily needed, but some programs may not use the more-correct VISUAL
. See VISUAL
vs. EDITOR
.
Fixing compatibility issues
Some editors require a --wait
flag, or they will open a blank page. For example:
Sublime Text (if correctly set up; or use the full path to the executable in place of
subl
):export VISUAL="subl --wait"
VS Code (after adding the shell command):
export VISUAL="code --wait"

- 24,552
- 19
- 101
- 135

- 52,552
- 5
- 33
- 28
-
115The EDITOR environment variable has the advantage that a number of other programs will respect it as well. – Boojum Apr 08 '10 at 00:45
-
20Note that `git config --global` would write to your personal (per-user) git configuration file. On Unices it is `~/.gitconfig`. So this would configure it for all your repositories. – Jakub Narębski Apr 08 '10 at 14:12
-
61you can test you successfully changed it by trying to amend the last commit message. `git commit --amend` – Marco M. Aug 27 '12 at 15:27
-
15If you're doing option #1 in Windows and have spaces in the path to the editor (say, if it's under Program Files) then whack single-quotes inside your double-quotes. e.g. "'C:/Program Files (x86)/Whatever/App.exe'" - obvious to some but it wasn't to me! – Pablissimo Oct 31 '13 at 15:51
-
1You should change your answer to git config --global core.editor "vim -w" to actually allow the user to write a commit message. – Abramodj Apr 02 '14 at 13:13
-
5@Abramodj `-w` is not necessary; `-w {scriptout}` saves all characters you type when editing to replay later. Perhaps you are confusing it with `-f`, which *is* necessary when calling the GUI version of Vim. That is, if you use `mvim`, then the editor you specify should be `mvim -f` rather than `mvim`. – Rory O'Kane Oct 13 '14 at 09:00
-
@RoryO'Kane, Thanks for the -f tip for mvim(i.e. `macvim`)! Both -w and -W didn't work correctly for me. With -w I got `Aborting commit due to empty commit message.`, and -W opened a vim welcome window. – 7stud Oct 05 '15 at 05:02
-
If you have both `core.editor` and `GIT_EDITOR` set, `GIT_EDITOR` will be used. This is nice for setting default via git config and overriding the config for individual commands if needed. For example, I just needed `$ GIT_EDITOR=nano git rebase -i origin/master` because my X was not available to use my regular editor. – Mikko Rantalainen Jan 12 '17 at 09:25
-
2for sublime text 3: `git config --global core.editor "subl -n -w" ~ ` – yaitloutou Jan 31 '17 at 09:19
-
[For Windows users](https://stackoverflow.com/q/10564/3357935), you can use Notepad with `git config --global core.editor "notepad"` – Stevoisiak Aug 17 '17 at 15:46
-
ISSUE: On a mac , configured with "core.editor=mvim --nofork --remote-wait", I find that if I have OTHER vim windows open, unrelated to the git update/session, the --remote-wait requires ALL of them to be closed before git recognizes it's editor session as completed. Need to make the --remote-wait ONLY apply to the single window launched for that git editor session. Any suggestions? – Andrew Ward Oct 30 '17 at 17:42
-
I just posted a more thorough Sublime Text answer here: https://stackoverflow.com/a/48212377/4561887. Thanks for your answer on it to get me started! – Gabriel Staples Jan 11 '18 at 17:10
-
If you're having an issue setting up Sublime (or any installed editor, really) often supplying the full path fixes the issue: `git config --global core.editor "'C:/Program Files/Sublime Text 3/subl.exe' --wait"` – KayakinKoder Jul 04 '18 at 16:15
-
[It's best to set `$EDITOR` to `vim -e`](https://unix.stackexchange.com/a/4861/143394) to be pedantically safe. – Tom Hale Aug 27 '20 at 13:33
-
How could I set editor for git merge ? Does the core editor cover that as well? – alper Aug 25 '21 at 22:11
-
`git config --global core.editor "vim"` worked for me in Laravel Homestead – Pathros Nov 16 '21 at 22:39
-
In case of Nano, you can add a vertical line at specified length of line (for example to count the length of lines in commits). To do that, type: `git config --global core.editor "nano -J 80"` – Grzegorz Maj Jun 13 '23 at 08:41
Run:
git config --global core.editor "vim"
From man git-commit
:
ENVIRONMENT AND CONFIGURATION VARIABLES
The editor used to edit the commit log message will be chosen from the
GIT_EDITOR
environment variable, thecore.editor
configuration variable, theVISUAL
environment variable, or theEDITOR
environment variable (in that order).

- 24,552
- 19
- 101
- 135

- 249,864
- 45
- 407
- 398
-
4Btw, the above is true for CVS and SVN, and I guess other version controls. – armandino Apr 08 '10 at 00:33
-
6@armandino: Yes, the others might use `VISUAL` or `EDITOR`, but they certainly don't use `GIT_EDITOR` or `core.editor`. – Mark Rushakoff Apr 08 '10 at 00:35
-
Thanks for clarifying Mark. I meant the EDITOR variable. I believe the GIT_EDITOR (if defined) simply overrides it. – armandino Apr 08 '10 at 00:39
-
8Yep - http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1.3.2 So in theory, if I'm using both svn and git, setting $VISUAL or $EDITOR would be the best solution to cover both by default! – brasskazoo Apr 08 '10 at 00:43
-
12For the sake of completeness, core.editor means [core] editor = ... in the file – JRG Aug 08 '11 at 21:53
-
From [Pro Git](http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration): "By default, Git uses whatever you’ve set as your default text editor ($VISUAL or $EDITOR) or else falls back to the vi editor to create and edit your commit and tag messages. " Isn't this order a reversal to what you're citing from `man git-commit`? – Nick Volynkin Jul 23 '15 at 20:05
On Ubuntu and also Debian (thanks @MichielB) changing the default editor is also possible by running:
sudo update-alternatives --config editor
Which will prompt the following:
There are 4 choices for the alternative editor (providing /usr/bin/editor).
Selection Path Priority Status
------------------------------------------------------------
0 /bin/nano 40 auto mode
1 /bin/ed -100 manual mode
2 /bin/nano 40 manual mode
* 3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 10 manual mode
Press enter to keep the current choice[*], or type selection number:

- 25,449
- 7
- 83
- 78
-
8
-
3Of course it works on Debian; it's a Debian feature, which, like most things (ooh, controversial!), Ubuntu merely inherits. Debian's `alternatives` system is a much easier way to manage defaults for the supported program types. For reference: https://www.debian-administration.org/article/91/Using_the_Debian_alternatives_system – underscore_d Jan 22 '16 at 11:35
-
-
@haziz: On my system, one of the listed options is Emacs (others include various versions of Vim, plus nano and ed). – Dennis Williamson Jan 11 '17 at 01:19
-
3@haziz `update-alternatives` will show any editors that have been installed. Koen just doesn't have Emacs installed. – Major Aug 09 '18 at 16:07
-
When I install `vim-gtk3` on my Ununtu 16.04 (and I suspect 18.04), the default is automatically switched to `vim`, until then I have `nano` as the default. So I think that may be why some people never need to run this command and it works as expected. – Alexis Wilke Oct 31 '19 at 19:55
-
In windows 7, while adding the "Sublime" editor it was still giving me an error:
Aborting commit due to empty commit message.
Sublime was not able to keep the focus.
To fix this I opened the .gitconfig file in c:/users/username/ folder and added the following line with --wait option outside the single quotes.
[core]
editor = 'F:/Program Files/Sublime Text 2/sublime_text.exe' --wait
Hope its helpful to somebody facing similar issue with Sublime.

- 30,436
- 41
- 178
- 315

- 15,075
- 10
- 50
- 60
-
Nice! Thanks Anmol, I was having that issue where it was committing on an empty message. – ddavison Oct 11 '13 at 17:12
-
-
17Any editor for git commit will mostly be used to add multiple lines of comments and Sublime is a programmer choice for various reason for many developers. People generally have a tendency to use one editor for most of their coding and other works. Sublime is just a personal choice, it can be any editor. – Anmol Saraf May 01 '14 at 21:31
-
1Instead of editing gitconfig manually you can use this command `git config --global core.editor "'C:/Program Files/Sublime Text 3/subl.exe' --wait"` – KayakinKoder Jul 04 '18 at 16:16
In Windows 7, setting editor to Notepad++
- Open any text editor.
- Open this file:
C:\Users\YOUR_USERNAME\.gitconfig
- Add this section to the bottom:
For 64 bit Notepad++ use:
[core]
editor = 'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar
For 32 bit Notepad++ use:
[core]
editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar
- Save and close the file.
- When you're committing with git, just write
git commit
and pressEnter
. It will pop open Notepad++. - Write your commit message at the top of the file, and save and close the file. Done!

- 1,225
- 1
- 19
- 27

- 22,332
- 31
- 176
- 357
-
finally someone who knows how to write it simple! Thanks. But you should mentioned, that in the path to notepad have to be used '/' or double backslash '\\', otherwise git will complain... – icl7126 Apr 19 '13 at 14:19
-
11You may need to add at least `-multiInst` as a parameter to notepad++ and possibly `-notabbar`. Do this if git doesn't seem to know when you've finished editing the file and either waits forever or not at all. – ErikE Sep 06 '13 at 00:12
-
5to set the config on the commandline, I need double quotes inside single quotes like `>git config --global core.editor '"C:/Program Files (x86)/Notepad++/notepad++.exe"'` – Josef Apr 28 '15 at 00:55
-
-
@ErikE: Thanks man! Both `-multiInst` and `-notabbar` were required. This was bugging for the last few hours. – Technext Aug 03 '16 at 08:47
-
3To add the Notepadd++ params, I had to do this: `editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar` - that is, params outside the delimiting single quotes – cropredy Jan 25 '17 at 01:20
-
without the quotes, you'd need a lot of escaping: [core] editor = c:/Program\\ Files\\ \\(x86\\)/Vim/vim81/vim.exe – XPlatformer Jun 03 '19 at 11:48
To make Visual Studio Code (vscode
) the default git editor:
git config --global core.editor "code --wait"

- 24,552
- 19
- 101
- 135

- 6,750
- 2
- 34
- 43
And if you are working with designers using the command line then Pico, and dont know short cuts ;)
git config --global core.editor "pico"
Or
export VISUAL=pico
export EDITOR=pico

- 4,427
- 1
- 26
- 30
Atom as your git editor
git config --global core.editor "atom --wait"
Atom needs to be configured to run from the command line for the above to work:
OS X: install shell commands from Atom: menu bar > Atom > Install Shell Commands
Windows: no action required - atom is configured to run from the command line by default
Setting Sublime Text 2 as Git commit editor in Mac OSX 10
Run this command:
$ git config --global core.editor "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
Or just:
$ git config --global core.editor "subl -w"

- 14,023
- 6
- 43
- 67

- 64,437
- 34
- 159
- 186
-
Somehow it's not delivering the text to git. I got 'Aborting commit due to empty commit message.' error. – Mahendran Aug 20 '15 at 06:50
-
I have used the first command to setup SL. cmd + S then cmd +W to close editor – Mahendran Aug 20 '15 at 06:51
-
2Visual Studio Code also support the `-w` parameter. Eg. `$ git config --global core.editor "code -w"`. Neat stuff – Automatico Aug 27 '17 at 22:37
-
Alternate answer here: https://stackoverflow.com/a/48212377/4561887, with Linux example. – Gabriel Staples Jan 11 '18 at 17:14
To make vim the default editor for git on ubuntu 20:04 run the following command:
git config --global core.editor vim

- 1,979
- 24
- 28
This provides an answer for people who arrive at this Question that may want to link an editor other than vim.
The linked resource, by Github,is likely to be kept up to date, when editors are updated, even if answers on SO (including this one) are not.
Associating Text Editors with git
Github's post shows exactly what to type in to your command line for various editors, including the options/flags specific to each editor for it to work best with git.
Notepad++:
git config --global core.editor "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
Sublime Text:
git config --global core.editor "'c:/Program Files/sublime text 3/subl.exe' -w"
Atom:
git config --global core.editor "atom --wait"
The commands above assume your editor has been installed in the default directory for a windows machine.
The commands basically add the text between double-quotes to .gitconfig
in your home directory.
On a windows machine home is likely to be C:\Users\your-user-name
, where your-user-name is your login name.
From the command line, you can reach this directory by typing in cd ~
.
for example, a command above would be add the following line under the [core]
section like so:
[core]
editor = 'C:/Program Files/sublime text 3/subl.exe' -w
If you have a different editor, just replace with the path to your editor, using either method above. (and hope no flags are needed for optimal usage.)

- 16,580
- 17
- 88
- 94
-
Thanks, I was struggling with the fact that just "vim" launched the "internal" vim instance for Git (without my preferences, etc.). Providing the full path to my instance solved the issue! – benichka Jul 25 '19 at 15:27
Windows: setting notepad as the default commit message editor
git config --global core.editor notepad.exe
Hit Ctrl+S to save your commit message. To discard, just close the notepad window without saving.
In case you hit the shortcut for save, then decide to abort, go to File->Save as, and in the dialog that opens, change "Save as type" to "All files (*.*)". You will see a file named "COMMIT_EDITMSG". Delete it, and close notepad window.
Edit: Alternatively, and more easily, delete all the contents from the open notepad window and hit save. (thanks mwfearnley for the comment!)
I think for small write-ups such as commit messages notepad serves best, because it is simple, is there with windows, opens up in no time. Even your sublime may take a second or two to get fired up when you have a load of plugins and stuff.

- 16,753
- 12
- 73
- 90
-
2Instead of going to File->Save as, you could blank the file (or comment out any non-blank lines), and then Git will abort due to an empty commit message. – mwfearnley May 04 '16 at 08:04
-
better you add the line like this `core.editor = 'notepad' .git/COMMIT_EDITMSG --wait` so it opens and saves the default edit message and you dont need "save as" – Radon8472 Feb 06 '18 at 23:59
For emacs users
.emacs
:
(server-start)
shellrc
:
export EDITOR=emacsclient

- 787
- 3
- 12
-
6Here's how to set emacs in terminal mode when comiting `git config --global core.editor "emacs -nw"` – kukinsula Apr 28 '16 at 13:41
-
1I use `git config --global core.editor "emacs -nw -q"`, where the `-q` skips initialization files. – miguelmorin Oct 31 '18 at 23:10
Best settings for Sublime Text 3 or 4 as your Git editor (Windows & Linux instructions):
To follow these instructions in Windows make sure you have installed Git for Windows. In Windows, I like to use Git Bash so that it feels more like Linux.
First, we want to create a special Sublime Text project so that we can specify special project settings we want set whenever Git calls the editor, to make things easier when editing in Git. For example, I normally set my ruler to 120 chars in most projects, but for Git commit messages I want it to be 72 characters so that it fits nicely in a terminal when you call git log
or git lg
.
1. Create a Sublime Text project with settings we want to use to edit Git commit messages
Open Sublime Text and go to menu "File" → "New Window" to create a new anonymous project. Go to menu "Project" → "Save Project As..." and choose a place to save it. In Linux I saved it in my Linux home directory with the file name .gitconfig.sublime-project
. Its path is therefore: ~/.gitconfig.sublime-project
. In Windows also save it in your home directory, for example: C:\Users\MY_USER_NAME\.gitconfig.sublime-project
Now go to menu "Project" → "Edit Project" to edit the project settings. Paste the following and save the settings. Make any further edits for your project settings if desired.
{
// For folder settings help see here: https://www.sublimetext.com/docs/3/projects.html
"folders":
[
],
"settings":
{
// Disables horizontal scrolling if enabled.
// May be set to true, false, or "auto", where it will be disabled for
// source code, and otherwise enabled.
"word_wrap": false,
// Set to a value other than 0 to force wrapping at that column rather than the
// window width
"wrap_width": 0,
// Columns in which to display vertical rulers
"rulers": [72, 50], //72 is recommended by git for commit message content, and 50 for commit titles
// The number of spaces a tab is considered equal to
"tab_size": 4,
// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": true,
},
"build_systems":
[
]
}
2. Set the editor to be used by Git
Now we need to set the editor to be used by Git, by editing the .gitconfig
file.
For Linux:
Your user copy of this will be located in ~/.gitconfig
. Open this file and add the following lines. Be sure to use the proper path name to the Git project you just created above! I'm using ~/.gitconfig.sublime-project
.
[core]
editor = subl --project ~/.gitconfig.sublime-project --wait
The --wait
is important, as it forces Git to wait until you close the file before it continues on. The --project
line is important to tell Sublime Text which project you want opened whenever Git opens Sublime Text.
Per @digitaldreamer's answer above (https://stackoverflow.com/a/2596835/4561887), "subl
can be replaced by the full path of the executable but [the alias subl
] is usually available when [Sublime is] correctly installed."
For Windows:
For Windows, first read the Linux instructions for background information. Now we will do something almost identical.
(OPTIONAL, but highly recommended: create a subl
alias for use in Git Bash):
Open up a text editor (for example, Notepad, Notepad++, Sublime Text, Geany, etc.), and create a file called .bash_profile
in your home directory, if it doesn't already exist. You can also use .bashrc
, which is probably more-recommended. Its path will therefore be: C:\Users\MY_USER_NAME\.bash_profile
or C:\Users\MY_USER_NAME\.bashrc
. Save the following into it:
# (copy and paste this into the bottom of your ~/.bashrc (recommended) or
# ~/.bash_profile file)
alias subl="/c/Program\ Files/Sublime\ Text/subl.exe"
This creates a Git Bash alias called subl
that we can now use in Git Bash for Windows, to easily open Sublime Text. This step isn't required, but it's useful for general Git Bash use. Close and re-open your Git Bash terminals. Now, you can call subl .
, for instance, in Git Bash to open up a new Sublime Text project in your current directory.
(MANDATORY):
Edit the .gitconfig
file found in your home directory: C:\Users\MY_USER_NAME\.gitconfig
, by adding the following to it. Notice the subtle changes from the Linux instructions above:
[core]
editor = 'C:/Program Files/Sublime Text/subl.exe' --project ~/.gitconfig.sublime-project --wait
- Notice that you must specify the full path to the Sublime Text executable. Note the direction of the slashes! Use
/
NOT\
to separate folders in the path name! (Thanks VonC for helping me see this). - Our
subl
alias we made for Git Bash above doesn't work in the.gitconfig
settings above, so you can't use it like we did in the Linux example. Instead, you must specify the whole path as shown above. - The
~
symbol, however, does still work here to get to your Windows home directory.
2.5. (Optional, but recommended) Install the "Git" package into Sublime Text 3.
This gives you syntax highlighting for git commit
messages, as well as access to other Git commands such as git blame
(which I use frequently in Sublime Text) or git commit
(which I don't use in Sublime Text since I'd prefer the command-line for general Git flow, as I've mentioned in my comments below this answer).
To install a package: First, ensure “Package Control” is installed. Next, press Ctrl + Shift + P (same as Tools → Command Palette) and type all or part of “Package Control: Install Package”, then press Enter. In the search box that comes up, search for the package "Git" and hit Enter on it, or click on it, to automatically install it.
Once installed, Ctrl + Shift + P then searching for "git" will bring up Git commands you can use internally inside Sublime Text now, such as git blame
.
3. Use it
Now when you call git commit
, for instance, as normal from the command-line, Sublime Text will open up into the .gitconfig.sublime-project
we created above, with that project's settings! As you type a paragraph you'll notice it extends past the ruler we set since soft word-wrap is off. To force hard wrap via auto-inserted hard-returns at the end of each line, put your cursor on the long line you want auto-wrapped and press Alt + Q. It will now hard-wrap/hard-fold at 72 characters, which is what we set in the project settings' "rulers" parameter above.
Now, save your commit message with Ctrl + S, and exit (to complete your git commit
) with Ctrl + Shift + W.
Done!
Related:

- 36,492
- 15
- 194
- 265
-
1
-
In Sublime Text 3, there is now a `Git Commit` syntax type. You can skip the custom "sublime-text project" step now. – yegeniy Apr 03 '18 at 14:16
-
I disagree: that does syntax highlighting only. My custom project doesn't touch syntax higlighting: it sets rulers and gives a context for your git commits to open up in so they don't open up in whatever project you have or last had open. The two are unrelated; do them both. – Gabriel Staples Apr 03 '18 at 15:37
-
I just added step 2.5, BUT (bit "but" here): I don't always use Sublime Text 3 as my editor (sometimes I use Eclipse since it has far superior symbol tracking and indexing than Sublime even though it's otherwise a crappy editor compared to Sublime), and I really prefer to use Git from the command-line, so I most definitely do not recommend skipping Step 1 even if you install the "Git" package into Sublime as I've described in Step 2.5 just now. Yes you can do Git Commits straight from Sublime but I'd prefer the command line. – Gabriel Staples Apr 03 '18 at 15:50
-
1TIP: If you use `sublime` with `git` and also use `trim_trailing_white_space_on_save` you want to add an alias for patch adding because removing trailing white space breaks patch edits where it's very much meaningful. This can be achieved with something like this: `git config --global alias.patch "-c core.editor=vim add --patch"` – Timo Aug 24 '18 at 05:46
You could either:
git config --global core.editor "vim"
Or, in your .gitconfig
:
[core]
editor = vim

- 6,148
- 6
- 38
- 76
there is a list of commad that you can use but for vs code use this
git config --global core.editor "code --wait"
this is the link for all editor :https://git-scm.com/book/en/v2/Appendix-C%3A-Git-Commands-Setup-and-Config

- 624
- 9
- 16
Set core.editor in your Git config:
git config --global core.editor "nano"
Set the GIT_EDITOR environment variable:
export GIT_EDITOR=nano

- 165
- 1
- 5
Mvim as your git editor
Like all the other GUI applications, you have to launch mvim with the wait flag.
git config --global core.editor "mvim --remote-wait"

- 259
- 1
- 9
For Mac OS X, using TextEdit or the natural environmental editor for text:
git config --global core.editor "open -W -n"

- 30,738
- 21
- 105
- 131

- 4,278
- 40
- 52
For Windows users who want to use neovim with the Windows Subsystem for Linux:
git config core.editor "C:/Windows/system32/bash.exe --login -c 'nvim .git/COMMIT_EDITMSG'"
This is not a fool-proof solution as it doesn't handle interactive rebasing (for example). Improvements very welcome!

- 1,042
- 2
- 11
- 33
Simplest way to make Neovim as your default Git editor in Linux
git config --global core.editor "nvim"
Done

- 2,339
- 19
- 22
Just because I came here looking for a one-time solution (in my case, I usually use vim
but this one time I wanted to use VS Code) for a single command and others might want to know as well:
GIT_EDITOR='code -w' git rebase -i …
Here's my git
/hub
version just for context:
git version 2.24.2 (Apple Git-127)
hub version 2.14.1

- 3,259
- 5
- 27
- 42
For users of TextWrangler from the Mac app store:
git config --global core.editor "open -n -W -a TextWrangler"
Also, make sure your "TextWrangler > Preferences > Application > When TextWrangler becomes active:" setting is set to "Do nothing"
This works for me on OS X 10.11.4 with TextWrangler 5.0.2 from the Mac app store.
Explanation:
The -n means open in a new instance.
The -W means to wait until the application exits before using the contents of the edited file as the commit message.
The -a TextWrangler means use the TextWrangler application to open the file.
See man open
in your Mac Terminal app for more details.

- 13,876
- 4
- 53
- 70
-
If TextWrangler is already open your solution will open another instance with the same file set of the first one. This seems dangerous. – Klaas Oct 07 '16 at 14:02
-
I did install the TextWrangler command line tools (http://www.barebones.com/support/textwrangler/cmd-line-tools.html) and then used `git config --global core.editor "edit -w"`. This will open the commit message in the current instance and as soon as you close only this commit message document, the commit will continue. – Klaas Oct 07 '16 at 14:04
When using git-review
I had to modify sequence.editor
value to be able to do interactive rebase (git rebase -i -p
):
git config --global sequence.editor "gvim" # or whatever your prefer
gvim
require: apt install vim-gtk
References

- 40,270
- 28
- 126
- 178
On macOS Big Sur (11.0) beta for TextMate: none of the environment variable options worked. (Set all three: GIT_EDITOR, VISUAL, and EDITOR.)
Finally set the global core.editor in git, and that worked:
git config --global core.editor "~/bin/mate -w"

- 7,940
- 48
- 77
For Windows, Neovim:
# .gitconfig
[core]
editor='C:/tools/neovim/Neovim/bin/nvim-qt.exe'

- 6,105
- 2
- 37
- 45
git config --global core.editor "code --wait"
To revert the changes made to the Git configuration and restore the default editor, you can use the following commands:
git config --global --unset core.editor

- 491
- 4
- 11
Just try EDITOR=vim git commit
.
Or you can set your EDITOR to vim by export EDITOR=vim
in your bashrc.

- 1,402
- 16
- 11
For Textmate Users
This opens Textmate editor in when you want to edit your commits. Requires textmate command line tools to be installed.
git config --global core.editor "mate -w"

- 14,023
- 6
- 43
- 67

- 9,548
- 8
- 49
- 66
-
-
2
-
hmm no it isn't, but if you use something else than vim (such as textmate). – Matej Jan 09 '14 at 12:21
-
textmate also has a "wait" option, so for me, it's this: `git config --global core.editor "/usr/local/bin/mate -w"` – trungly Jul 10 '15 at 18:55
For Windows users who want to use Kinesics Text Editor
Create a file called 'k.sh', add the following text and place in your home directory (~):
winpty "C:\Program Files (x86)\Kinesics Text Editor\x64\k.exe" $1
At the git prompt type:
git config --global core.editor ~/k.sh

- 12,626
- 10
- 72
- 101
For IntelliJ users
When i was trying to git rebase i was getting the following error: 'hint: Waiting for your editor to close the file... code -n -w: code: command not found error: There was a problem with the editor 'code -n -w'.'
The same error showed up when i was trying to associate IntelliJ with Git:
The problem was that I did not have the command code added in my environment PATH variable. And i didn't want to use Visual Studio Code from my terminal. So that is why it prompted "command not found". I solved this by deleting
editor = code -n -w
from the core section in my .gitconfig file. Git worked properly again.

- 138
- 1
- 4
For EmEditor users
To set EmEditor as the default text editor for Git, open Git Bash, and type:
git config --global core.editor "emeditor.exe -sp"
EmEditor v19.9.2 or later required.

- 1,761
- 2
- 5
- 9
For MAC, BBEdit:
First, open BBEdit, click on the BBEdit logo, and choose Install Command-Line Tools.
Then from the command line,
git config --global core.editor "BBEdit -w"

- 5,011
- 5
- 36
- 47
On Fedora you can just run:
sudo dnf install --allowerasing vim-default-editor
(Restart of the terminal may be required afterwards.)

- 111
- 1
- 4