Fundamentals 7 min read

Master Git Global Configuration in 5 Simple Steps

Learn how to set up Git globally on Linux by creating a global config file and configuring your default name, email, branch name, and editor, with clear command examples and tips to avoid repetitive per‑repository settings.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Git Global Configuration in 5 Simple Steps

Configuring Git on Linux is straightforward, and using a global configuration eliminates the need to repeat settings for each repository.

1. Create a global configuration file

If the file does not exist, Git can create it with the --edit option and open it in your default editor. $ git config --global --edit The newly created ~/.gitconfig will contain a template like:

# This is Git's per-user configuration file.
[user]
#   name = Your Name
#   email = [email protected]

2. Set the default user name

Add the name entry under the [user] section, either via the command line or by editing the file directly.

name = Alan Formy-Duval

3. Set the default email address

Specify the email that Git will use for commits. email = [email protected] Or run the command:

$ git config --global user.email "[email protected]"

4. Set the default branch name

Replace the legacy master default with main (or any preferred name) by adding an init section.

[init]
    defaultBranch = main

5. Set the default editor

Define which editor Git should invoke for commit messages.

[core]
    editor = vi
Note: the tilde ( ~ ) represents your home directory, e.g., /home/alan .

Viewing the configuration

You can inspect the global settings with:

$ cat ~/.gitconfig
[user]
    email = [email protected]
    name = Alan Formy-Duval
[core]
    editor = vi
[init]
    defaultBranch = main

This concise guide provides the essential commands to quickly start using Git with a personalized global configuration.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

GitTutorialversion-control
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.