Configuring Git
Set up your Git identity, default settings, and line endings before making your first commit. Takes 5 minutes.
Git is installed but not yet ready to use. Before you make your first commit, you must tell Git two things:
- Who you are — your name and email address
- How it should behave — default branch name, line endings, editor
These settings are stored globally on your computer and apply to every project you work on. You set them once.
Why Your Identity Matters
Every Git commit is permanently signed with the name and email address of the person who made it. This is not optional. Git refuses to create a commit if it doesn't know who you are.
Think of it like signing a document. In a CA firm, every work paper is signed by the person who prepared it. This is not about tracking you — it is about accountability and traceability. When someone looks at a commit three months from now, they need to know: who made this change, so they can ask questions about it.
Your commit author information appears:
- In
git log(the history list) - On GitHub next to every change you push
- In any pull request or code review
Use the same email you registered with GitHub. This links your local commits to your GitHub identity — commits will show your GitHub avatar and profile on the GitHub website.
The Configuration Commands
Open a terminal — Git Bash (preferred) or Command Prompt — and run these commands one by one, replacing the values with your actual information.
Set Your Name
Run: git config --global user.name "Your Full Name"
Example: git config --global user.name "Priya Sharma"
Include the quotation marks. If your name has a space (which it will), the quotes tell Git that the whole string is one value.
Set Your Email
Run: git config --global user.email "your@email.com"
Example: git config --global user.email "priya@example.com"
Use the same email address you used when creating your GitHub account. This links commits to your GitHub profile.
Set the Default Branch Name
Run: git config --global init.defaultBranch main
When you create a new project with Git, the first branch is called main. (Older Git installations default to master — we want main everywhere to match GitHub's standard.)
Set Line Ending Behavior on Windows
Run: git config --global core.autocrlf true
Windows and Unix systems (Linux/macOS) use different characters to mark the end of a line in text files. Windows uses CRLF. Unix uses LF. This difference causes unnecessary noise when comparing files across operating systems.
What this does in plain language: When you pull code from GitHub (which uses Unix line endings), Git converts it to Windows line endings on your machine. When you commit code back, Git converts it back to Unix line endings for storage. You never see or think about this conversion — it just works.
This is a Windows-specific setting. Mac and Linux users set this to input or false. If a colleague on Mac gives you their configuration commands, don't copy this line from theirs — it should be true on Windows.
Set VS Code as the Git Editor
Run: git config --global core.editor "code --wait"
When Git needs you to write a message (for a complex merge, for example), it opens a text editor. By default on some systems this is Vim, which has an unusual interface that confuses beginners. Set it to VS Code instead.
The --wait flag tells Git to wait for VS Code to close before continuing. Without it, Git would move on immediately, before you've finished writing.
Verify Your Configuration
To see everything Git has stored about your identity and settings, run: git config --list
You should see output similar to this, with your actual values:
user.name=Priya Sharmauser.email=priya@example.cominit.defaultbranch=maincore.autocrlf=truecore.editor=code --wait
Confirm that:
user.nameshows your actual name (with correct spelling)user.emailshows the exact email you used for GitHub (including the domain)init.defaultbranchshowsmaincore.autocrlfshowstrue
git config --list and confirm all five lines appear. If anything is missing or incorrect, re-run the relevant command from the steps above.A common mistake: Using a different email here than on GitHub. If user.email in Git doesn't match your GitHub account email, your commits will not be linked to your GitHub profile. They will appear as "anonymous" commits on GitHub — you'll see the commit content but your avatar and profile link won't appear. Fix it immediately by re-running git config --global user.email "your-correct@email.com" with the correct address.
Checking a Specific Setting
If you only want to check one value, run git config user.name or git config user.email.
These return just the value for that key — useful for quickly confirming one thing without reading the full list.
Where These Settings Are Stored
All global Git configuration is stored in a single file at ~/.gitconfig — where ~ is your home directory (C:\Users\YourName\).
You can open this file in VS Code to see its contents: run code ~/.gitconfig in Git Bash.
The file is a standard .ini-style configuration file — readable plain text. You can edit it directly if you know what you're doing, but for now the git config commands are the right way to make changes.
If you ever move to a new computer, copy your .gitconfig file to the new machine and your Git settings transfer instantly — name, email, editor, all preferences. Zero reconfiguration.
Project-Level Configuration
The --global flag in all the commands above sets configuration for every project on your computer. Git also supports project-level configuration — settings that apply only to one specific project.
For this program, global configuration is all you need. Project-level configuration is used in team environments where different projects might use different email addresses (for example, a developer using a personal email for personal projects and a work email for company projects).
If you ever need project-level settings, run the same commands from inside the project folder but without --global:
This writes to a .git/config file inside the project folder and overrides the global setting for that project only.
Summary: Your 5 Configuration Commands
Run each of these once, with your actual information substituted:
git config --global user.name "Your Full Name"git config --global user.email "your@email.com"git config --global init.defaultBranch maingit config --global core.autocrlf truegit config --global core.editor "code --wait"
Then verify with: git config --list
When you see all five values reflected correctly, Git is fully configured. You're ready to use it.
git config --list in Git Bash. Confirm you can see your name, your email, main as the default branch, true for autocrlf, and code --wait as the editor. All five should appear before you move on.Next Step
Git is installed and configured. Now learn the 10 commands you'll use 95% of the time.