Book Image

Gitlab Cookbook

By : Jeroen van Baarsen
Book Image

Gitlab Cookbook

By: Jeroen van Baarsen

Overview of this book

Table of Contents (16 chapters)
GitLab Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

How to change your Git editor


When you create a Git commit with git commit –a, the default editor that will be opened is Vim. This can be very confusing for people, as Vim is not an easy editor if you have never worked with it previously.

Luckily, Git allows you to change the editor that gets opened by default very easily!

There are two ways in which this can be done. The first is via the terminal; this is useful if you want your editor to be Nano, for example. The command to do this is git config --global core.editor "nano". You can change the highlighted section with your editor of choice!

Another way to do this is to edit the .gitconfig file in your home directory. The location of this file depends on the operating system you're using. The possible locations are as follows:

  • Windows: C:/users/your_username/

  • Linux / Mac OS X: /home/your_username

When you open this file in your favorite editor, you need to find the following line:

[core]
      editor = 'vim'

It might be possible that this line is not yet present in the file; in that case, you need to add it. You can change vim to your favorite editor. When you save and close the file and try to perform a Git commit, you will have your own editor!