What your Git username is and where it appears

Your Git username is the name that appears next to every commit you make — the author line that shows who wrote the code. It is not your GitHub account name, your computer login, or your email address, though any of those could be what you chose to use. Git stores this name locally on your machine, and you set it yourself the first time you make a commit.

When you run git log or look at a repository's history, you see commits listed with an author name. That name comes from your Git configuration, not from any online service. Two people on the same computer can have different Git usernames if they each configure their own.

If you have already made commits, your username is already set. If you are starting fresh or cannot remember what you set it to, the steps below show you how to check and change it.

Key Takeaways

  • Your Git username is stored on your computer in a configuration file, separate from your GitHub or GitLab account name.
  • Check your current username by opening a terminal and running git config user.name.
  • Set or change your username by running git config --global user.name "Your Name" to explore it to all repositories on your machine.
  • If you set it without the --global flag, the username applies only to the current repository.
  • Your Git username and email are stored in a plain text file you can edit directly if the command line feels unfamiliar.

Check your current Git username from the terminal

Open a terminal or command prompt on your machine. On Mac or Linux, use the Terminal app. On Windows, use Command Prompt, PowerShell, or Git Bash if you have it installed.

Type this command and press Enter:

git config user.name

If a username appears, that is what Git will use for your commits. If nothing appears, your username is not set yet and you will need to configure it before you make your first commit.

You can also see both your username and email together by running git config --list. This shows all your Git settings at once. Look for the lines that start with user.name and user.email.

Set your Git username for all repositories

To set a username that Git will use for every repository on your machine, use the --global flag. Type this command, replacing "Your Name" with the name you want to use:

git config --global user.name "Your Name"

Press Enter. Git does not print a confirmation message, but the setting is now saved. You can verify it worked by running git config user.name again — your new name should appear.

The --global flag stores your username in a configuration file on your computer that Git reads every time you work with a repository. This is the most common way to set it, because you usually want the same name on all your projects.

Set your Git username for a single repository

If you want a different username for just one project, navigate to that repository's folder in your terminal first. Then run the same command without the --global flag:

git config user.name "Your Name"

This setting applies only to that repository. When you work in other repositories, Git will use your global username instead. This is useful if you work on personal projects with one name and professional projects with another.

To check which username applies to the current repository, run git config user.name without any flags. Git shows the repository-specific setting if one exists, otherwise it shows the global one.

Edit your Git configuration file directly

If you prefer not to use the terminal, you can edit the configuration file by hand. On Mac and Linux, the global configuration file is located at ~/.gitconfig in your home directory. On Windows, it is usually at C:\Users\YourUsername\.gitconfig.

Open this file in any text editor. You will see sections like [user] with lines underneath. Find or create the [user] section and add or change the line to read:

[user] name = Your Name

Save the file. The next time you make a commit, Git will use this name. For a repository-specific setting, look for a .git/config file inside the repository folder itself and edit it the same way.

What name to use for your Git username

Git does not enforce any format — you can use your real name, a nickname, your GitHub username, or anything else. The name you choose appears in the commit history forever, so pick something you are comfortable with other developers seeing.

If you work on open-source projects or collaborate with others, using your real name or a consistent handle makes it easier for people to know who wrote each piece of code. If you work only on private projects, the choice is entirely yours.

You can change your Git username at any time by running the configuration command again with a new name. Old commits keep the name they were made with — changing your username does not rewrite history.

Frequently Asked Questions

Is my Git username the same as my GitHub username?

No. Your Git username is stored on your computer and is what appears in commit history. Your GitHub username is your account name on GitHub's website. They can be the same, but they do not have to be. GitHub shows the commit author name from Git, not your account name.

Do I need to set my Git username before making my first commit?

Yes. If you try to make a commit without setting a username and email, Git will refuse and tell you to configure them first. Set both your username and email before you make your first commit.

Can I have a different Git username on different computers?

Yes. Each computer has its own Git configuration file. You can set one username on your laptop and a different one on your desktop. The settings do not sync between machines unless you manually copy the configuration file.

What if I set my username wrong and want to change it?

Run the configuration command again with the correct name. New commits will use the new username. Commits you already made keep the old username — Git does not rewrite history when you change your configuration.

Where does Git store my username?

Git stores your global username in a plain text file called .gitconfig in your home directory. Repository-specific usernames go in a config file inside the .git folder of that repository. Both are readable text files you can view or edit with any text editor.