How to Change the Git Editor for Commits

Abdul Jabbar Feb 02, 2024
  1. Use the Terminal to Change the Git Editor
  2. Edit the .gitconfig File to Change the Git Editor
How to Change the Git Editor for Commits

In Git, we can change the default editor used in typing commits to push to remote repositories.

This tutorial will demonstrate how to switch to the Git editor of our choice through two configuration methods.

Use the Terminal to Change the Git Editor

If we want our editor to be nano, below is the command that we will use to change the editor.

git config --global core.editor "nano"

As we can see, there is a highlighted section that we can change according to which editor we want.

In the windows system, if we want to set other text editors, we should specifically mention the entire path of the file to be executed.

Edit the .gitconfig File to Change the Git Editor

The other way to change the Git editor is to edit the .gitconfig file in our home directory. The file’s location can be traced depending on the operating system.

The following are examples of setting a default Git editor on different operating systems.

Operating System Configuration command
Mac, with command line tools git config --global core.editor "bbedit -w"
Linux git config --global core.editor "gedit --wait --new-window"
Windows 64-bit git config --global core.editor "'C:\Program Files\Vim\vim72\gvim.exe' --nofork '%*'"
Author: Abdul Jabbar
Abdul Jabbar avatar Abdul Jabbar avatar

Abdul is a software engineer with an architect background and a passion for full-stack web development with eight years of professional experience in analysis, design, development, implementation, performance tuning, and implementation of business applications.

LinkedIn

Related Article - Git Commit