How to configure your Git identity in VS Code
Git needs to know who you are before you can commit code. VS Code does not store this information itself — it reads from your Git configuration, which lives on your computer. You set your username and email once in Git, and every commit you make from any process (VS Code, the command line, or anywhere else) will carry that identity.
The fastest way is to open VS Code's built-in terminal and run two commands. This takes about one minute and works whether you are on Windows, Mac, or Linux. Your commits will then display your name and email to anyone who views the repository history.
Key Takeaways
- Git stores your username and email in a configuration file on your computer, not in VS Code itself.
- You can set this information using the terminal inside VS Code by running two git config commands.
- Use the --global flag to set your identity for all projects on your computer, or omit it to set it only for the current project.
- You can verify what you have set by running git config --list in the terminal.
- Your username and email appear on every commit you make, so use the name and email you want associated with your work.
Opening the terminal in VS Code
Start by opening the integrated terminal. On Windows or Linux, press Ctrl + ` (backtick, the key above Tab). On Mac, press Ctrl + ` or go to the menu and select Terminal > New Terminal.
A terminal window will open at the bottom of VS Code. You should see a command prompt — usually a $ or > symbol. This is where you type Git commands. If you see an error message instead, Git may not be installed on your computer yet.
Setting your username globally
Type this command and press Enter:
git config --global user.name "Your Name"
Replace "Your Name" with the name you want on your commits. This can be your real name, a nickname, or any text you choose. Keep the quotation marks. For example: git config --global user.name "James Rodriguez"
The --global flag means this setting applies to every project on your computer. If you want this username only for the current project, run the same command without --global. The command will complete silently — no message means it worked.
Setting your email globally
Now type this command and press Enter:
git config --global user.email "your.email@example.com"
Replace "your.email@example.com" with the email address you want on your commits. This is often the email you use for GitHub, GitLab, or another Git hosting service, but it can be any email address. Keep the quotation marks.
Again, --global applies this to all projects. Without it, the setting applies only to the current project folder. Like the username command, this will complete without any confirmation message.
Verifying your settings
To confirm that Git has stored your username and email, type this command and press Enter:
git config --list
A list of all your Git settings will appear. Look for the lines that say user.name= and user.email=. If you see your username and email there, you are done. If you used --global, these settings will appear in the list. If you set them only for the current project, they will show up only when you run this command inside that project folder.
Changing your username or email later
If you need to change either value, run the same commands again with the new information. Git will overwrite the old setting with the new one. For example, if you want to change your email:
git config --global user.email "newemail@example.com"
This replaces your previous email globally. Run git config --list again to confirm the change took effect. Any commits you make after this point will use the new email address.
Setting different identities for different projects
You might want to use one email for work projects and another for personal projects. To do this, navigate to the project folder in VS Code, open the terminal, and run the git config commands without the --global flag:
git config user.name "Work Name"
git config user.email "work@company.com"
Now commits in this project folder will use "Work Name" and "work@company.com", while all other projects use your global settings. This is useful when you work on both personal and professional repositories on the same computer.
Frequently Asked Questions
Does my username have to match my GitHub username?
No. Your Git username is just a label on your commits. Your GitHub username is separate. However, if you want commits to link to your GitHub profile, you should use the email address associated with your GitHub account.
What if I use the wrong email and already made commits?
The commits you already made will keep the old email. New commits will use the new email. If you need to change the email on old commits, that requires rewriting history, which is complex and not recommended unless you have a strong reason.
Can I see who made a commit?
Yes. Run git log in the terminal to see a list of all commits in your project, including the author name and email for each one. This shows you exactly what identity was used when each commit was made.
Do I need to set this up in VS Code settings?
No. VS Code reads from your Git configuration file, not from VS Code settings. The terminal commands are the correct way to do this. VS Code has no built-in interface for setting Git identity.
What if the terminal says "git is not recognized"?
Git is not installed on your computer. read it from git-scm.com, install it, then restart VS Code. After that, the terminal will recognize git commands.