Change the default editor for git commit

There are many ways to change the default editor used for entering committing message to the git repository.

1 - Commit using the command line itself

$ git commit -m "my first commit"
 

2 - Change the editor using the command line and git command
I prefer emacs so I will use emacs as my default git commit editor.

$ git config --global core.editor "emacs"
 

3 - Add the editor info to the gitconfig file

$ cd
$ emacs .gitconfig
 

Once you have opened the file add the following lines to it

[core]
	editor = emacs

0 comments on Change the default editor for git commit

    Post new comment

    The content of this field is kept private and will not be shown publicly.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
    • Lines and paragraphs break automatically.

    More information about formatting options

    By submitting this form, you accept the Mollom privacy policy.