Change the default diff or commit editor for git


Git Commit Editor

If you want to change the default editor that is used when you diff or commit to git, you need to make use of the git config command to set the global value for core.editor

Example 1: To set the editor as vi (or vim)
% git config --global core.editor vi
Example 2: To set the editor as nano
% git config --global core.editor nano
Example 3: To set the editor as sublime
% git config --global core.editor "subl -n -w"
Example 4: To set the editor as visual studio code (vscode)
% git config --global core.editor "code -w"
Example 5: To set the editor as Nodepad++
% git config --global core.editor "C:/Program Files/Notepad++/notepad++.exe' -multiInst"
Example 6: To set the editor as Atom
% git config --global core.editor "atom -w"

Once you set your favorite editor, you will see that the commit command opens it up!


# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Changes to be committed:
#       new file:   a.txt
#
~                                                                                                    
~                                                                                                    
~                                                                                                    
~                                                                                                    
"/myproj/.git/COMMIT_EDITMSG" 8L, 206B                                             1,0-1  


















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap