Check your Git configuration in three commands
Your Git email and username are stored in a configuration file on your computer. You can see what Git has recorded by opening your terminal or command prompt and running one of three commands — each shows a different scope of settings.
The fastest way is to run git config user.name to see your username and git config user.email to see your email. Each command returns only that one value. If nothing appears, Git has not stored that setting yet.
If you want to see both at once, run git config --list. This shows all your Git settings in one output, including user.name and user.email along with other configuration details. Scroll through the output or search for "user." to find the lines you need.
Key Takeaways
- Run git config user.name or git config user.email in your terminal to check one setting at a time.
- Run git config --list to see your username and email together with all other Git settings on your machine.
- If no output appears, you have not set that value yet and should configure it before making your first commit.
- Settings stored with --global explore to all repositories on your computer; settings without it explore only to the current repository.
- Your Git email and username appear in every commit you make, so verify they are correct before you start working.
Understanding global versus local settings
Git stores settings at two levels: global (your whole computer) and local (one repository only). When you check your configuration, Git shows you both, but you need to know which one is actually being used.
Run git config --global user.name to see only your global username, or git config user.name (without --global) to see the local setting for the current repository. If you have set a local value, Git uses that for commits in that folder. If you have not, Git falls back to your global setting.
This matters because you might use one email for work repositories and a different one for personal projects. Check both levels if your commits are going out under the wrong name or email.
Where Git stores these settings
Your global configuration lives in a hidden file called .gitconfig in your home directory. On Windows, this is usually C:\Users\YourUsername\.gitconfig. On Mac or Linux, it is ~/.gitconfig.
You can open this file in any text editor to see your settings directly, though using the git config commands is simpler and safer. Local settings for a single repository are stored in a hidden folder called .git inside that repository, in a file called config.
If you want to edit your settings by hand instead of using commands, you can open .gitconfig and look for lines that say [user], followed by name = YourName and email = your@email.com. Save the file and Git will read the changes when ready.
What to do if your settings are wrong
If you see the wrong email or username, you can change it with git config --global user.name "Your Name" or git config --global user.email "your@email.com". Use these commands without the --global flag to change only the current repository.
The new setting takes effect when ready for any commits you make going forward. It does not change commits you have already made — those keep the old email and username. If you need to fix a commit you just made, you can use git commit --amend --author="Your Name <your@email.com>" to rewrite it.
If you have pushed commits to a server like GitHub or GitLab, changing your local Git config will not change those commits on the server. The commits are permanent. You would need to force-push the corrected version, which can cause problems if others are working from the old version.
Why Git needs your email and username
Every commit you make records your name and email as the author. This creates a permanent record of who wrote each line of code and when. On platforms like GitHub, your email is used to link commits to your account and show your contribution graph.
If your email does not match the one registered on GitHub or GitLab, your commits may not show up in your profile or contribution history, even though they are in the repository. This is why checking your Git email before your first commit matters — it is easier to set it right than to fix it later.
Your email is also visible to anyone who can see the repository, so use an email you are comfortable sharing publicly. Many developers use a work email for work repositories and a personal email for open-source projects.
Checking Git email on different operating systems
On Windows, open Command Prompt or PowerShell and type git config user.email. If Git is not recognized, you may need to install Git for Windows or add it to your system path.
On Mac, open Terminal (in Applications > Utilities) and type git config user.email. Git usually comes pre-installed, but if you see "command not found", install it through Xcode Command Line Tools by running xcode-select --install.
On Linux, open your terminal and type git config user.email. If Git is not installed, use your package manager: sudo apt install git on Ubuntu or Debian, or sudo yum install git on Red Hat or CentOS.
Frequently Asked Questions
What if git config returns nothing?
If the command returns no output, you have not set that value yet. Run git config --global user.name "Your Name" and git config --global user.email "your@email.com" to set them. After that, the commands will return your values.
Can I have different emails for different repositories?
Yes. Set a global email with --global, then navigate to a specific repository folder and run git config user.email "different@email.com" without --global. Git will use the local setting for that repository and the global setting for all others.
Does changing my Git email change old commits?
No. Changing your Git configuration only affects new commits you make. Old commits keep the email and name that were recorded when you made them. If you need to fix an old commit, you must rewrite it with git commit --amend or a rebase.
Why does my GitHub profile not show my commits?
GitHub links commits to your account by matching the email in the commit to an email registered on your GitHub account. If your Git email does not match any email on your GitHub profile, the commits will not show in your contribution graph. Add the email to your GitHub account settings or change your Git email to match one that is already there.
Can I see who made a commit and when?
Yes. Run git log to see a list of all commits with the author name, email, date, and commit message. Run git log --oneline for a shorter view, or git show [commit-hash] to see details of one specific commit.