After installing Git and initially configuring it, you can further configure it to use your favorite text editor as the default. What you need to do is set the value of core.editor to the program file of your editor and add a flag -w at the end. The -w basically is to tell Git to wait until all operations within the text editor is done before Git can continue to do its thing afterwards.
git config --global core.editor '"C:\Program Files\Sublime Text 4\sublime_text.exe" -w'
Pay attention to the placement of single quote (‘) and double quotes (“). You want to enclose the whole path of your editor within the quotes, then wrap the whole argument with the flag with the other.
You can use single quote or double quotes interchangeably as long as they’re consistent
"'C:\Program Files\Sublime Text 4\sublime_text.exe' -w" works the same way as in the example above).
macOS / Linux
git config --global core.editor "subl -n -w"
Now, if you want to see if the text editor is set correctly, just type in this command:
git config --global --list
And you should see the core.editor value listed to look like this:
Sublime Text is used as an example just because it’s available on Windows, OSX, and Linux. You can certainly substitute the path or program name with whatever text editor you have.
Using Visual Studio Code
Update 9/27/2021: If you use Visual Studio Code as your main editor, the setup is even more simple and this is actually is the more recommended setup now since this post was published (Visual Studio Code can be downloaded from the link at the bottom of this post).
You just need to type the following:
git config --global core.editor "code -w"
If you use macOS, before this configuration can work, you need to setup Visual Studio Code so it can be called from the command line. Then the Git setup to use it is the same on both Windows and macOS.