Initial Git Setup

Jan 01, 2025

2 min read

Git

Setting Up Git for the First Time 

Before using Git, it is essential to configure it properly. The most common initial setup includes setting your name and email, which are used to sign commits, defining the default text editor, and adjusting behavior settings such as case sensitivity.

To configure Git, use the following commands:

# Set your name (this appears in commit history)
git config --global user.name "Your Name"

# Set your email (this is associated with commits)
git config --global user.email "your.email@example.com"

# Set the default text editor (optional, e.g., VS Code)
git config --global core.editor "code --wait"

Why Setting a Global Git name and email Can Be Problematic 

Setting your Git username and email globally may seem convenient, but it has significant drawbacks:

  1. Multiple Identities: If you contribute to both work and personal repositories, a global setting might lead to commits being signed with the wrong email.
  2. Security Concerns: Using a personal email for public repositories can expose your email to spam or phishing attempts.
  3. Organization-Specific Policies: Some companies require you to use corporate emails for commits, and a global setting can lead to non-compliance.

A Better Approach 

Instead of setting your name and email globally, configure them per repository:

cd /path/to/repo

git config user.name "Work Name"
git config user.email "work.email@company.com"

This ensures each repository has the correct identity while avoiding unintended email exposure.

Understanding core.ignorecase 

One often-overlooked Git setting is core.ignorecase. By default, on Windows and macOS, Git is case-insensitive due to how the underlying file system handles case differences. This means that files named README.md and readme.md could be considered the same file.

To ensure that Git respects case sensitivity, you can disable case ignoring with:

git config core.ignorecase false

This setting prevents accidental issues where developers working on different operating systems encounter conflicts due to inconsistent casing in filenames.

Making core.ignorecase a Global Setting 

By default, core.ignorecase is a repository-level setting. However, if you want to apply it globally, you can run:

git config --global core.ignorecase false

This ensures that case sensitivity is preserved across all repositories on your system, preventing potential filename conflicts, especially in environments where different OS behaviors come into play.

Share this article