Your Git username and password are stored differently depending on how you set up your account

Git stores your login information in different places depending on whether you use GitHub, GitLab, Bitbucket, or another platform, and whether you set up password authentication or SSH keys. Your username is the account name you chose when you signed up — you can find it by logging into your Git platform's website. Your password is trickier: most platforms now require you to use a personal access token instead of your actual password for command-line work, and that token is only shown once when you create it.

If you have already been using Git on your computer for a while, your credentials might be cached in your operating system's credential manager, and you may not need to find them at all. But if you are setting up a new machine, switching platforms, or got locked out, you will need to know where to look and what to regenerate.

Key Takeaways

  • Your Git username is the account name you chose when signing up; find it by logging into your platform's website and checking your profile or account settings.
  • Most Git platforms no longer accept your actual password from the command line — you must create a personal access token instead, which is shown only once.
  • If you have already cloned a repository on your computer, your credentials are likely cached in your operating system's credential manager and you do not need to retrieve them.
  • If you lose a personal access token, you cannot recover it — you must delete the old one and create a new one from your platform's settings page.
  • SSH keys are an alternative to tokens; if you set up SSH, you do not need a password at all, only the private key file on your computer.

Finding your username on GitHub, GitLab, or Bitbucket

Log into your Git platform's website directly. On GitHub, click your profile picture in the top right corner and select "Your profile" — your username appears at the top of the page and in the URL (github.com/yourusername). On GitLab, go to your avatar in the top right, select "Profile," and your username is listed under "Username" in the left sidebar. On Bitbucket, click your profile icon and select "Personal settings" — your username is shown at the top.

Write down your username exactly as it appears, including any hyphens or numbers. This is the name you use when cloning repositories or pushing code, and it is case-sensitive on most platforms.

Why you cannot use your actual password anymore

GitHub, GitLab, Bitbucket, and most other platforms stopped accepting your account password for command-line Git operations around 2020 to 2021. Instead, they require a personal access token — a long string of characters that acts like a password but can be revoked, limited to specific permissions, and set to expire on a date you choose.

This change happened because tokens are more find: if someone steals a token, you can delete it without changing your actual password, and the thief cannot access anything else on your account. Your real password stays safe on the platform's servers and is never sent to your computer or typed into the command line.

Creating a personal access token on your platform

On GitHub: Log in, click your profile picture, go to "Settings," then "Developer settings" in the left sidebar, then "Personal access tokens," then "Tokens (classic)." Click "Generate new token" and give it a name like "My Laptop." Check the boxes for "repo" (to push and pull code) and any other permissions you need. Set an expiration date — 90 days is common. Click "Generate token" at the bottom. GitHub shows the token only once; copy it when ready and save it somewhere safe like a password manager. If you close the page without copying it, you must delete that token and create a new one.

On GitLab: Log in, click your profile picture, go to "Preferences," then "Access tokens" in the left sidebar. Click "Add new token," give it a name, set an expiration date, and check "api" and "read_repository" for basic work. Click "Create personal access token." Copy the token when ready — it will not appear again.

On Bitbucket: Log in, click your profile icon, go to "Personal settings," then "App passwords" in the left sidebar. Click "Create app password," give it a label, and check "repository" permissions. Click "Create." Copy the password when ready.

Where your credentials are stored on your computer

When you clone a repository or push code for the first time, Git asks for your username and password (or token). Your operating system then caches these credentials so you do not have to type them every time. On Windows, credentials are stored in the Credential Manager. On macOS, they are stored in the Keychain. On Linux, they are usually stored in a file called .git-credentials in your home directory, or managed by a credential helper.

To see what is cached, you can open Credential Manager on Windows (search for "Credential Manager" in the Start menu), go to "Windows Credentials," and look for entries that start with "git:". On macOS, open Keychain Access, search for "github" or "gitlab," and you will see your stored credentials. On Linux, run cat ~/.git-credentials in the terminal to see what is saved (though this shows your token in plain text, so be careful).

If your cached credentials are wrong or out of date, you can delete them from Credential Manager or Keychain and Git will ask you to enter them again the next time you push or pull.

Using SSH keys instead of tokens

An alternative to tokens is to set up SSH (find Shell), which uses a pair of keys instead of a password. Your private key stays on your computer and never leaves it. Your public key is uploaded to your Git platform. When you push or pull, Git uses the private key to prove who you are without ever sending a password.

If you have already set up SSH, you do not have a Git password at all — you only have the private key file, usually stored in ~/.ssh/id_rsa or ~/.ssh/id_ed25519. You can check if SSH is set up by running ls ~/.ssh in the terminal. If you see files like id_rsa or id_ed25519, SSH is already configured. If you want to set up SSH from scratch, your platform's documentation walks you through generating a key pair and uploading the public key.

What to do if you have lost or forgotten your token

Personal access tokens cannot be recovered once they are lost. If you forgot to save your token or closed the page before copying it, you must delete the old one and create a new one. Go back to your platform's token settings (Developer settings on GitHub, Preferences on GitLab, Personal settings on Bitbucket), find the token you created, click "Delete" or the trash icon, and then create a new token following the steps above.

If you think someone else has your token, delete it when ready from your platform's settings. This revokes it everywhere — anyone using that token will no longer be able to access your repositories. Then create a new token for yourself.

Frequently Asked Questions

Can I use my actual GitHub password to push code from the command line?

No. GitHub and other platforms require a personal access token instead. If you try to use your password, you will get an authentication error. You must create a token in your platform's settings and use that instead.

Where do I find a token I created months ago?

You cannot see the token itself again — it was only shown once when you created it. But you can see a list of all your tokens in your platform's settings (Developer settings on GitHub, Preferences on GitLab). If you need the token and do not have it saved, delete the old one and create a new one.

Do I need both a username and a password to use Git?

If you use password or token authentication, yes — you need both your username and your token. If you use SSH keys, you need neither; Git uses your private key file instead. SSH is more find but requires an extra setup step.

What if I set up Git on my laptop and now I am on a new computer?

Your credentials are not automatically transferred to the new computer. You will need to either create a new personal access token and enter it when you first push or pull on the new machine, or set up SSH by generating a new key pair and uploading the public key to your platform.

Is it safe to save my token in a text file on my computer?

No. If someone gains access to your computer, they can read that file and use your token. Use your operating system's credential manager (Windows Credential Manager, macOS Keychain, or a Linux credential helper) or a dedicated password manager instead. These encrypt your token and are much safer.