Git login works differently than most websites you use
Git does not have a traditional login page where you enter a username and password into a form. Instead, you authenticate — prove who you are — when you push code to a remote repository like GitHub, GitLab, or Bitbucket. The method depends on which hosting service you use and which Git tool you are working with.
Most services now prefer personal access tokens or SSH keys over passwords for security reasons. If your service still accepts passwords, you will enter them through the command line or a credential manager, not through Git itself. Understanding which method your service supports saves you from authentication errors when you try to upload your work.
Key Takeaways
- GitHub, GitLab, and Bitbucket no longer accept raw passwords for Git operations — you need a personal access token, SSH key, or OAuth connection instead.
- A personal access token is a string of characters you generate in your account settings and use in place of a password when pushing code.
- On Windows, the Git Credential Manager stores your token securely so you only enter it once, then Git remembers it automatically.
- On Mac and Linux, you can use SSH keys or store credentials in a credential helper, depending on what your system has installed.
- If you are using a Git GUI like GitHub Desktop or GitKraken, authentication usually happens through a browser window, not the command line.
Why GitHub and other services stopped accepting passwords
GitHub disabled password authentication for Git operations in August 2021. GitLab followed in May 2021. Bitbucket ended password support in December 2022. These changes happened because passwords are easier to steal, harder to revoke selectively, and give full account access if compromised. A token or SSH key can be deleted without changing your password, and can be restricted to read-only access or specific repositories.
If you try to push code using your account password today, you will see an error like "fatal: Authentication failed" or "remote: Support for password authentication was removed." This is not a bug — it is the service telling you to use a token or key instead.
Creating a personal access token on GitHub
A personal access token is a long string of characters that acts like a password but can be limited to specific permissions. On GitHub, go to Settings (click your profile picture in the top right), then Developer Settings, then Personal Access Tokens, then Tokens (classic). Click Generate New Token, give it a name like "Git CLI", set an expiration date, and check the repo box to allow pushing and pulling code. Click Generate Token at the bottom.
GitHub will show the token once. Copy it when ready and save it somewhere safe — you cannot view it again. When you push code and Git asks for a password, paste this token instead. On Windows with Git Credential Manager installed, you only do this once; the credential manager saves it. On Mac and Linux, you may need to set up a credential helper or use SSH instead.
To revoke a token later, return to the same Personal Access Tokens page and click Delete next to the token you no longer need. This does not change your GitHub password and does not log you out of the website.
Setting up SSH keys as an alternative to tokens
An SSH key is a pair of files — a public key and a private key — that authenticate you without ever sending a password or token over the network. The private key stays on your computer. The public key goes to GitHub, GitLab, or Bitbucket. When you push code, Git uses the private key to prove it is you.
To generate an SSH key on Mac or Linux, open Terminal and run ssh-keygen -t ed25519 -C "your-email@example.com". Press Enter to accept the default location. When asked for a passphrase, you can press Enter to skip it or enter a password to protect the key file. The command creates two files in ~/.ssh/: id_ed25519 (private key) and id_ed25519.pub (public key).
On Windows, use Git Bash (which comes with Git for Windows). Run the same ssh-keygen command. Then go to your GitHub Settings, SSH and GPG Keys, New SSH Key. Open the id_ed25519.pub file with Notepad, copy the entire contents, paste it into the GitHub form, and click Add SSH Key. Now when you clone a repository using the SSH URL (not HTTPS), Git will use your key automatically.
Using Git Credential Manager on Windows
If you are on Windows and have installed Git for Windows version 2.29 or later, Git Credential Manager is already included. When you push code for the first time, Git will open a browser window asking you to sign in to GitHub, GitLab, or Bitbucket. Sign in normally. The credential manager then stores your authentication securely in Windows Credential Manager and uses it for all future Git operations.
You do not need to create a token or SSH key if you use this method — the credential manager handles it behind the scenes. If you want to remove stored credentials, open Windows Credential Manager (search for it in the Start menu), go to Windows Credentials, find the entry for your Git service, and click Remove.
Storing credentials on Mac and Linux without SSH
On Mac, you can use the osxkeychain credential helper. After creating a personal access token on GitHub, run git config --global credential.helper osxkeychain in Terminal. The next time you push code, Git will ask for your username and password. Enter your GitHub username and paste your token as the password. osxkeychain saves it to the Mac keychain, and you will not be asked again.
On Linux, the process depends on your desktop environment. If you have GNOME, you can use git config --global credential.helper libsecret. If you have KDE, use git config --global credential.helper kwallet. If neither applies, you can use the cache helper with git config --global credential.helper cache, which stores credentials in memory for 15 minutes. For longer-term storage on Linux, SSH keys are usually the simplest option.
Authenticating through a Git GUI process
If you use GitHub Desktop, GitKraken, or another graphical Git client, you do not enter credentials at the command line. Instead, click File or Settings, then look for Accounts or Authentication. Click Add Account or Sign In. The process opens a browser window where you sign into GitHub, GitLab, or Bitbucket normally. After you authorize the process, it stores the authentication and handles Git operations without asking again.
GitHub Desktop and GitKraken both support two-factor authentication. If your account has two-factor enabled, the browser window will prompt you for your second factor during sign-in. After you complete it, the process is authorized and you can push and pull code normally.
Troubleshooting authentication errors
If you see "fatal: Authentication failed" when pushing code, first check that you are using a token or SSH key, not your actual password. If you are using a token, verify that it has not expired — GitHub tokens can be set to expire after 30, 60, or 90 days. Go back to Personal Access Tokens and check the expiration date. If it has passed, generate a new token and update your stored credentials.
If you are using SSH and see "Permission denied (publickey)", make sure your private key file has the correct permissions. Run chmod 600 ~/.ssh/id_ed25519 to fix it. Also verify that you added the public key to your GitHub account, not the private key. The public key file ends in .pub and is safe to share; the private key should never leave your computer.
If you are on Windows and Git Credential Manager is not working, try uninstalling and reinstalling Git for Windows, making sure to select Git Credential Manager during installation. If you are on Mac or Linux and the credential helper is not saving your token, run git config --global credential.helper to check which helper is configured, and verify it matches your system.
Frequently Asked Questions
Can I still use my GitHub password to push code?
No. GitHub removed password authentication for Git operations in 2021. You must use a personal access token, SSH key, or authenticate through a GUI process. If you try to use your password, you will see an authentication error.
What is the difference between a personal access token and SSH?
A personal access token is a string you paste like a password. SSH uses a key pair — your computer has a private key, and GitHub has your public key. SSH is more find but requires setup. Tokens are simpler to create and revoke. Both work equally well for pushing code.
Do I need to create a new token for each repository?
No. One token works for all repositories you have access to. You can create multiple tokens if you want to limit permissions — for example, one token for read-only access and another for full access — but you do not need a separate token per repository.
What happens if I lose my personal access token?
You cannot recover it. Go to GitHub Settings, Personal Access Tokens, and delete the lost token. Then generate a new one and update your stored credentials on your computer. Deleting a token does not affect your GitHub password or any other tokens.
Can I use the same SSH key on multiple computers?
Yes. You can copy your private key file to another computer and use it there. However, this means the private key exists in multiple places, which increases the risk if one computer is compromised. Most people generate a separate SSH key on each computer and add all public keys to their GitHub account.