Git has a number of configuration options. I'll go over a few of the most common here, but you can find an extensive list of the possible configuration options in the Git documentation

Required Git Configuration

When you use Git, you're going to make commits, which are basically snapshots of the code at a given time, and each commit includes information about who created the commit. So, in order for Git to attribute your commits to you, you need to configure your identity. The two pieces of information we'll add are "user.name" and "user.email".

  • git config --global user.name "Your Name" (This will be the name associated with your commits.)
  • git config --global user.email "you@yourdomain.com" (This will be the email address associated with your commits.)

By passing the "--global" option, you are configuring Git for your entire system. This means these credentials will be used for all projects on your system. If you'd like to override these for a specific project, you can do that by running the same command without the "--global" option while inside that project.

More information about how this works can be found in the book "Pro Git" which is free to read online.

Recommended Git Configuration

When editing text files in the terminal, you'll probably use a text editor like VI or Nano. You can configure Git to use your editor of choice.

  • git config --global core.editor "vi" (This sets VI as the default editor)

Git is much easier to use in the command line if you enable colors. When you do, staged files are shown in green, untracked files are red etc. I highly recommend enabling colors, and the command is simple.

  • git config --global color.ui true

This last configuration is one that I needed to set when I used Git on my shared host. When I ran a command like "git log --oneline" it showed escaped characters like "ESC[m" instead of showing the output in the appropriate color as it should have. To fix this, I had to specify the core.page to be more (instead of the default less). (FYI: "more" and "less" are terminal applications.)

  • git config --global core.pager more

Note: This was not required on my local machine. In fact, it had the opposite effect. So, you may not need to make this change at all. My recommendation is that you not change it, unless you notice the issue I mentioned. If you'd like to change the core.pager back to "less" type the following:

  • git config --global core.pager less

Finally, you can see your Git configuration by typing the following command.

  • git config --list