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.
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-Duval3. 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 = main5. Set the default editor
Define which editor Git should invoke for commit messages.
[core]
editor = viNote: 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 = mainThis concise guide provides the essential commands to quickly start using Git with a personalized global configuration.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
