Fix Git Authentication Failed Error

Last Updated : 27 Mar, 2026

Git authentication failed errors occur when incorrect credentials or outdated authentication methods prevent access to remote repositories.

  • Ensure correct username and password or token are used.
  • Use personal access tokens instead of passwords when required.
  • Check and update saved credentials or authentication settings.

Common Causes of the Error

Occurs due to invalid credentials or changes in authentication settings.

  • Incorrect Username or Password: The simplest reason is entering the wrong username or password.
  • Outdated Credentials: Saved credentials that are no longer valid can cause this error.
  • Two-Factor Authentication (2FA): If 2FA is enabled on your Git hosting service, your regular password won't work.
  • Changed Password: If you've recently changed your password, your saved credentials may be outdated.
  • Token Expiry: If you're using a personal access token (PAT), it might have expired.

Steps to Solve the Error

Follow a structured process to identify and fix Git authentication issues.

Step 1: Creating a git repository and installing Git Bash

Create a Git repository to store your project files and ensure Git Bash is installed on your system. Once you understand basic Git operations like pushing code, you can proceed to handle authentication errors.

Step 2: Prepare Repository and Files

Create a sample (dummy) Git repository and keep the files ready that you want to upload to GitHub.

Creating dummy git repo
Creating dummy git repo 
Created successfully and prompted with quick setup
Created successfully and prompted with quick setup

Following image attached below shows the files which we are going to upload to the GitHub repository.

DEMO FILES
DEMO FILES

Step 3: Verify Git Installation

Check whether Git Bash is installed and working correctly on your system before proceeding.

Checking GitBash
Checking Git Bash

Step 4: Identify the Error

While pushing files to the repository, you may encounter the error: “remote: Invalid username or password / fatal: Authentication failed”
This guide focuses on resolving this specific issue.

error
error

Step 5: Resolve the Error

Generate Personal Access Token (PAT)

  • Go to GitHub Settings > Developer Settings > Personal Access Tokens > Tokens (classic).
  • Click on Generate New Token.
  • Create and copy the token.
GitHub Setting
Developer Settings
Token
Generate

Use Token for Authentication

  • Run the push command again in Git Bash
  • When prompted for credentials: Paste the generated token as the password or OR choose Sign in with your browser.
POPUP
POPUP

Complete Authentication

  • After successful login, you will be redirected to a confirmation page.
  • Close the browser tab and return to Git Bash.
Succeded
Succeeded

After completing authentication, return to Git Bash to confirm the error is resolved and files are successfully pushed.

UPLOADED successfully
Uploaded successfully

Verify the repository on GitHub to confirm that files are successfully pushed and the authentication error is resolved.

Verifying by visiting GitHub repo (UPLOADED successfully)
Verifying by visiting the GitHub repo (UPLOADED successfully)
Comment

Explore