Whether you’re configuring Git on a new machine, collaborating on a project, or troubleshooting Git issues, it’s often helpful to know what Git username you’re using. Depending on context, this could refer to your local Git username (used for commits) or your GitHub account username (used for online repositories).
In this guide, weβll show you how to find both quickly and easily.
π What Is a Git Username?
There are two common contexts for a “Git username”:
- Local Git Username β This is configured in your Git installation and appears in your commit history.
- GitHub Username β This is your public username on GitHub, used to identify your online profile.
Letβs look at how to find both.
β How to Find Your Local Git Username
π Method 1: Check Your Global Git Configuration
Open your terminal or command prompt and run:
git config --global user.name
This will return the global Git username youβve set, such as:
John Doe
π Note: This is the name that appears in your commits. It doesnβt have to match your GitHub username, but it often does.
π Method 2: Check Repository-Specific Username
Git also allows you to override the username on a per-project basis.
To check the username for the current repository:
git config user.name
If nothing returns, the global config is used by default.
π§ Bonus: Find Git Email
To see the email associated with your commits:
git config --global user.email
Or for a specific repo:
git config user.email
β How to Find Your GitHub Username
If youβre working with GitHub (which most Git users do), you might need your GitHub account username, which is used for SSH, HTTPS URLs, or identifying contributors.
π Method 1: Check Your Profile URL
Log in to https://github.com and click on your profile picture (top-right). Select “Your profile”.
Your GitHub username will appear in the URL:
https://github.com/yourusername
And also displayed under your name on your profile page.
π Method 2: Git Remote URLs
If youβve already cloned a repository, you can extract your GitHub username from the remote URL.
Run:
git remote -v
Example output:
origin https://github.com/yourusername/project.git (fetch)
In this case, yourusername
is your GitHub username.
π How to Set or Change Your Git Username
If you need to set or update your Git username:
git config --global user.name "Your Name"
And to set your email:
git config --global user.email "yo*@ex*****.com"
β Summary
Task | Command or Location |
---|---|
View global Git username | git config --global user.name |
View local (repo-level) Git username | git config user.name |
View GitHub username | GitHub profile or git remote -v |
Change Git username | git config --global user.name "Your Name" |
Final Thoughts
Understanding the difference between your Git commit username and your GitHub account username helps you maintain consistent commits and avoid identity confusion when contributing to repositories. Whether youβre collaborating in a team or maintaining your own projects, keeping your Git identity clear and properly configured is good practice.