---
title: "Git Config Recommended Settings"
description: "“Git config” is not only a concept but a command. When first starting out with Git, a few configurations must be made right away. You can provide these configurations by running a few commands,..."
url: https://www.inmotionhosting.com/support/website/git/git-config/
date: 2020-12-30
modified: 2022-02-16
author: "Christopher Maiorana"
categories: ["Git"]
type: post
lang: en
---

# Git Config Recommended Settings

![](https://www.inmotionhosting.com/support/wp-content/uploads/2021/12/Git-Config-Recommended-Settings-1024x538.png)

“Git config” is not only a concept but a command. When first starting out with Git, a few configurations must be made right away. You can provide these configurations by running a few commands, but as you continue to use Git for more and more projects, you may have need more advanced configurations. In the latter case, you may find it helpful to create a configuration file that you can update and carry with you to other workstations — should the need arise.

- [Git Config Commands and Configuration](#config-commands)
- [Using Configuration Files](#using-config-files)
- [Recommended Configurations For Git](#recommended-configuration)
  - [Name and Email Configuration](#name-and-email)
  - [Git Aliases](#git-aliases)
  - [Remote Repositories](#remote-repos)
  - [Text Editor](#text-editor)

## Git Config Commands and Configuration

At the very least, in order to do a proper commit, Git requires that you submit your name and email address. You don’t have to use your real name or real email address, but these details are necessary to personalize your commits. A Git project would be chaotic if there was no way to tell who committed what and when.

These commands provide the personal data necessary to get started. For your name:

git config --global user.name "Joe Example"

And email:

git config --global user.email joe@example.com

These commands will configure your Git installation at the system level. But there are other levels for which you might to provide different configurations. More on those locations and files below.

## Using Configuration Files

Using configuration files for Git can provide a lot of value for you. First of all, you can more easily tweak and customize how you use Git. And being able to find these settings in a convenient location can also help you backup and share those settings with other users or across workstations.

Git will search three locations for configuration settings. Each successive level
overwrites values from the previous level. For example, values set in the project (`.git/config`) will overwrite those set for the system (`/etc/gitconfig`).

Learning about these different levels as locations in your file system will help you make sure you provide the right configuration in the right place.

System levelFirst, Git will look in the `/etc/gitconfig` file to identify any system-wide configurations. You can pass configurations to this file by adding the `--system` option to the default `git config` command.
Home levelThe home directory file `~/.gitconfig` contains the user level configurations that will only apply to the user.
Project levelIn the `.git/config` file, values are saved in the project working directory or repository and will thus affect the project.

Depending on how, when, and where you plan on updating these files, it’s up to you where you want to make these changes. For the sake of simplicity I would recommend first setting up the home directory file, `.gitconfig`, because your settings will only apply to your user account. If you plan on adding other users to your system, and you wish to apply some configurations globally or systemically then you would consider updating the other files as needed.

## Recommended Configurations For Git

Below you will find some recommended configurations for your local Git operations. These types of configurations are ideal additions to your local `~/.gitconfig` file that you will store in your home directory.

### Name and Email Configuration

Of course, first and foremost, Git requires that you provide a name and email with which to sign commits from your account. Every commit you make in Git must have a name and email attached, as a way of attributing work to the right person. You can add these to your local Git config likewise:

name = Joe Example
email = joe@example.com

If you do not have these values covered you will see an error when first trying to create a commit.

### Git Aliases

Adding aliases to your Git config speeds up your command input.

st = status
logg = log --graph --decorate --oneline --all
cm = commit
df = diff
dfs = diff --staged

To take an example from above, in order to run the `git status` command you can simply type `git st` and get the same result. Notice that you can provide even long strings of options and combinations and nest them all in one truncated input line.

### Remote Repositories

You can also add remote repositories right from the config file. In the example below, you have a remote repository called “origin,” to and from which you can `push` and `pull`.

url = git@example.come:/var/lib/git/production.git
fetch = +refs/heads/*:refs/remotes/origin/*

### Text Editor

When you initiate a commit with the `git commit` command, you are prompted to enter your commit message in a text editor. Here, you can specify which text editor you would prefer to use. In the example below, the `emacs` text editor is selected, but you could instead use `nano`, `gedit`, `vim`, or whatever editor you use regularly.

editor = emacs

---

Now you know what settings you will need for a solid Git configuration. Where will your Git journey take you next?

- [Git fundamentals (complete guide)](https://www.inmotionhosting.com/support/website/git/git-fundamentals-complete-beginner-guide/)
- [How to create your own git server](https://www.inmotionhosting.com/support/website/git/git-server/)
- [Launch a Gitweb installation with NGINX on Debian](https://www.inmotionhosting.com/support/website/git/gitweb-on-nginx/)
