DEV Community

Cover image for 🎯 Don’t Forget Your Git Identity: A Must-Do When Starting a New Project
alfanfauzy
alfanfauzy

Posted on • Edited on

🎯 Don’t Forget Your Git Identity: A Must-Do When Starting a New Project

🧠 Introduction

Starting a new job or contributing to a fresh project? One of the most overlooked steps is setting up your Git config—especially your name and email. If you skip it, your commits might be misattributed, or worse, tied to the wrong identity.

In this post, I’ll walk you through the importance of Git config, what happens if you ignore it, and how to set it up correctly using --local, --global, and --system scopes.


🤔 Why Git Config Matters

Every Git commit has two important fields:

  • Author: your name and email address
  • Committer: the person who actually applied the commit (often the same)

If you don’t configure your Git identity, Git might fallback to a system default or nothing at all. This can cause:

  • Commits linked to the wrong email (especially if you're on a shared or borrowed machine)
  • Inability to link commits to your GitHub profile (leading to missing contributions)
  • Inconsistent commit history in team projects

🛠 Git Config Scopes: --local vs --global vs --system

1. --local (most specific)

  • Configuration is stored in the current Git repository.
  • Use this when you're using a different identity for a specific project.
  git config --local user.name "Alfan Fauzy"
  git config --local user.email "alfan@newcompany.com"
Enter fullscreen mode Exit fullscreen mode

2. --global (user-wide)

  • Configuration is stored in your user directory (~/.gitconfig).
  • Applies to all repositories you work with unless overridden.
  git config --global user.name "Alfan Fauzy"
  git config --global user.email "alfan@personal.dev"
Enter fullscreen mode Exit fullscreen mode

3. --system (least common)

  • Configuration is stored in the system-wide Git config file (e.g., /etc/gitconfig).
  • Requires sudo/admin access and applies to all users on the system.
  sudo git config --system core.editor "vim"
Enter fullscreen mode Exit fullscreen mode

💡 Best Practices

  • Always check your Git config when starting a new job or project:
  git config --list --show-origin
Enter fullscreen mode Exit fullscreen mode
  • Use --local for work/company-related projects, especially when using a different GitHub or GitLab account.
  • Avoid --system unless you're managing shared environments or tooling.

✅ Quick Setup Guide

Here’s a checklist to run before committing to a new repo:

  # Check current Git config
  git config --list --show-origin

  # Set name and email locally for the repo
  git config --local user.name "Your Name"
  git config --local user.email "your@company.com"

  # Optional: Set your preferred editor
  git config --global core.editor "code --wait"
Enter fullscreen mode Exit fullscreen mode

🧵 Conclusion

Setting your Git identity might seem minor, but it's essential for maintaining clean, trackable history in your projects. Before your first commit, take a minute to check and set your Git config—it’ll save you and your team a lot of confusion down the road.


🔄 Feel free to share this with your team, especially if you're onboarding new developers!

💬 Have a Git tip to share? Drop it in the comments.

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.