Git Configuration
3.1 Setting Up User Information
Git records the author's name and email with every commit.
Set them globally (recommended for first-time setup):
To verify:
If you want to override these details for a specific repository only:
Set them globally (recommended for first-time setup):
1git config --global user.name "Your Name"
2git config --global user.email "your.email@example.com"To verify:
1git config --global --listIf you want to override these details for a specific repository only:
1git config user.name "Project Specific Name"
2git config user.email "project.email@example.com"3.2 Configuring Default Branch Name
By default, Git may use master as the main branch. You can set a preferred default branch name like main:
This ensures all new repositories start with main as the initial branch.
1git config --global init.defaultBranch mainThis ensures all new repositories start with main as the initial branch.
3.3 Setting Up the Default Editor
Git uses an editor for commit messages and rebase operations. You can configure your preferred editor:
1git config --global core.editor "code --wait" # VS Code
2git config --global core.editor "nano" # Nano
3git config --global core.editor "vim" # Vim3.4 Enabling Color Output
Make Git command output easier to read:
1git config --global color.ui auto3.5 Checking All Configurations
You can view all active configuration values with:
To see where a specific config is defined:
1git config --listTo see where a specific config is defined:
1git config --show-origin user.name3.6 Editing Configuration Files Directly
Git stores configurations in text files:
• System level: /etc/gitconfig
• Global level: ~/.gitconfig or C:\Users\<username>\.gitconfig
• Local level: .git/config inside the repository
Open .gitconfig for manual editing:
• System level: /etc/gitconfig
• Global level: ~/.gitconfig or C:\Users\<username>\.gitconfig
• Local level: .git/config inside the repository
Open .gitconfig for manual editing:
1git config --global --edit