Git push ошибка авторизации

I have been using GitHub for a little while, and I have been fine with git add, git commit, and git push, so far without any problems. Suddenly I am having an error that says:

fatal: Authentication Failed

In the terminal I cloned a repository, worked on a file and then I used git add to add the file to the commit log and when I did git commit, it worked fine. Finally, git push asks for username and password. I put those in correctly and every time I do this, it says the same error.

What is the cause of this problem and how can I fix it?

The contents of .git/config are:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = http://www.github.com/######/Random-Python-Tests
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[user]
        name = #####
        email = ############

Peter Mortensen's user avatar

asked Jul 15, 2013 at 16:34

zkirkland's user avatar

14

If you enabled two-factor authentication in your GitHub account you
won’t be able to push via HTTPS using your accounts password. Instead
you need to generate a personal access token. This can be done in the
application settings of your GitHub account. Using this token as your
password should allow you to push to your remote repository via HTTPS.
Use your username as usual.

Creating a personal access token

You may also need to update the origin for your repository if it is set to HTTPS. Do this to switch to SSH:

git remote -v
git remote set-url origin git@github.com:USERNAME/REPONAME.git

basZero's user avatar

basZero

4,1299 gold badges51 silver badges89 bronze badges

answered Jan 9, 2014 at 17:59

rc0r's user avatar

rc0rrc0r

18.7k1 gold badge16 silver badges20 bronze badges

21

On Windows, try the below steps to edit or remove the saved credentials:

  1. Click Start
  2. Type: Credential Manager (on Windows 10, this is under «StartSettings«. Then search for «Credential Manager»)
  3. See the Windows Credentials Manager shortcut and double-click it to open the application.
  4. Once the application is open, click on the Windows Credentials tab.
  5. Locate the credentials that you want to remove/update. They will start with «git:» and might begin with «ada:»
  6. Click on the credential entry. It will open a details view of the entry.
  7. Click Edit or Remove as required and confirm.
  8. Later rinse and repeat as necessary.

Enter image description here

answered May 1, 2018 at 6:41

Pradeep's user avatar

PradeepPradeep

12.3k3 gold badges20 silver badges25 bronze badges

11

Maybe you have changed the password recently for you Git account.
You could try the git push line with the -u option:

git push -u origin branch_name_that_you_want_to_push

After executing the above command, it will ask for a password. Provide your updated password.

Peter Mortensen's user avatar

answered May 10, 2017 at 7:44

Users9949's user avatar

Users9949Users9949

1,8191 gold badge12 silver badges11 bronze badges

6

It happens if you change your login or password of git service account (Git). You need to change it in Windows Credentials Manager too. type «Credential Manager» in Windows Search menu open it.

Windows Credentials Manager->Windows Credential and under Generic Credentials edit your git password.

answered Oct 14, 2019 at 7:04

Atif AbbAsi's user avatar

Atif AbbAsiAtif AbbAsi

5,6637 gold badges26 silver badges47 bronze badges

5

On Windows, this worked for me, and it also remembers my credentials:

  1. Run Git Bash

  2. Point to the repository directory

  3. Run git config --global credential.helper wincred

Peter Mortensen's user avatar

answered Jan 4, 2016 at 14:10

Utukku's user avatar

UtukkuUtukku

1,3351 gold badge10 silver badges6 bronze badges

5

Basically my credential was expired, and I was facing the issue.

The following two commands helped me:

git config --global --unset credential.helper

git config credential.helper store

It will ask you for credentials next time when you try to push.

Follow the below guidelines for more details for secured and unsecured storage of the user name and passwords:

  • git-credential-store

  • git-credential-cache

Peter Mortensen's user avatar

answered Apr 30, 2018 at 18:07

Jems's user avatar

JemsJems

1,0791 gold badge7 silver badges6 bronze badges

4

First, you can make sure to use the proper URL:

git remote set-url origin https://github.com/zkirkland/Random-Python-Tests.git

Then, if it was working before, and if it wasn’t asking for your username, it must be because you had stored your credentials (login/password) in a $HOME/.netrc file, as explained here. You can double check those settings, and make sure that your proxy, if you have one, hasn’t changed.

Check the output of git config --global credential.helper.
And make sure the credentials are your GitHub user account, and a PAT (Personal Access token).

You can update your credentials using the Git credential helper, as in here.


If that still doesn’t work, you can switch to an SSH URL:

git remote set-url origin git@github.com:zkirkland/Random-Python-Tests.git

But that means you have published your SSH public key in your Account settings.


For Visual Studio Code specifically, see also «git push: Missing or invalid credentials. fatal: Authentication failed for ‘https://github.com/username/repo.git'»

You can unselect the setting git.terminalAuthentication to avoid the error message.

answered Jul 16, 2013 at 8:12

VonC's user avatar

VonCVonC

1.3m530 gold badges4425 silver badges5265 bronze badges

5

On Windows, if you found an authentication error problem when you entered the correct password and username, it’s a Git problem. To solve this problem, when you are installing the Git in your machine, uncheck the Enable Git Credential Manager option.

Enter image description here

Peter Mortensen's user avatar

answered Mar 27, 2017 at 6:52

Hoque MD Zahidul's user avatar

Hoque MD ZahidulHoque MD Zahidul

10.6k2 gold badges37 silver badges40 bronze badges

4

I was getting the same error. I tried all the solutions whichever mentioned in this page, but they didn’t work. Finally, I found the solution.

These kinds of error comes if sometimes your system password has changed recently anytime. It will try to validate from the old password. So, follow these steps:

  1. Go to Control Panel
  2. Click on User Accounts
  3. Under Credentials manager
  4. Go to Manage Windows Credentials
  5. Go to Generic Credentials
  6. Expand the Git server tab
  7. Click on Remove from vault
  • Also, you can click Edit and change your password stored here directly.

Peter Mortensen's user avatar

answered Jun 10, 2019 at 7:46

xoxo's user avatar

xoxoxoxo

1,2481 gold badge14 silver badges19 bronze badges

2

I think that for some reason GitHub is expecting the URL to NOT have subdomain www. When I use (for example)

git remote set-url origin https://www.github.com/name/repo.git

it gives the following messages:

remote: Anonymous access to name/repo.git denied
fatal: Authentication failed for https://www.github.com/name/repo.git

However, if I use

git remote set-url origin https://github.com/name/repo.git

it works perfectly fine. Doesn’t make too much sense to me… but I guess remember not to put www in the remote URL for GitHub repositories.

Also notice the clone URLs provided on the GitHub repository webpage doesn’t include the www.

Chei's user avatar

Chei

2,1173 gold badges20 silver badges33 bronze badges

answered Jan 28, 2014 at 2:30

Electo's user avatar

ElectoElecto

5205 silver badges7 bronze badges

2

Before you try everything above, try to git push again, yes it works on me.

answered Sep 14, 2020 at 14:13

Justin Herrera's user avatar

3

The same error (Windows, Git Bash command line). Using https which should prompt for login credentials but instead errors:

$ git pull origin master
fatal: Authentication failed for 'https://github.com/frmbelz/my_git_project.git'
$ git config -l
...
credential.helper=manager
...

$ git config --global --unset credential.helper
$ git config --system --unset credential.helper

git pull now prompted for username/password prompts.

answered Jul 8, 2021 at 20:53

Vladislav Povorozniuc's user avatar

1

I’m not really sure what I did to get this error, but doing:

git remote set-url origin https://...

didn’t work for me. However:

git remote set-url origin git@bitbucket.org:user/repo

somehow worked.

answered Feb 4, 2014 at 19:15

Kafeaulait's user avatar

KafeaulaitKafeaulait

6641 gold badge6 silver badges14 bronze badges

2

I was adding to Bitbucket linked with Git and had to remove the stored keys, as this was causing the fatal error.

To resolve, I opened the command prompt and ran

 rundll32.exe keymgr.dll, KRShowKeyMgr

I removed the key that was responsible for signing in and next time I pushed the files to the repo, I was prompted for credentials and entered the correct ones, resulting in a successful push.

answered May 13, 2020 at 14:30

William Humphries's user avatar

1

I’ve ran into

git fetch

fatal: Authentication failed for 'http://...."

after my Windows password had expired and was changed. Multiple fetches, reboot and even reinstall of Git with Windows Credential Manager didn’t help.

Surprisingly the right answer is somewhere here in comments, but not in answers (and some of them are really weird!).

You need to go to Control PanelCredential ManagerWindows Credentials and update you password for git:http://your_repository_address

Peter Mortensen's user avatar

answered Jun 29, 2017 at 10:37

amarax's user avatar

amaraxamarax

5085 silver badges14 bronze badges

In my case, I recently changed my windows password and I have SSH key configured for git related actions (pull, push, fetch etc.,), after I encountered the «fatal: Authentication failed» error, I updated my password in the windows credential manager (Control Panel\User Accounts\Credential Manager)for all items starting with git:…, and tried again, worked this time!

answered Mar 13, 2020 at 14:27

Kiran Modini's user avatar

I had the same problem. I set the URL in this way:

git remote set-url origin https://github.com/zkirkland/Random-Python-Tests.git

I also removed this entry from the configuration file: askpass = /bin/echo.

Then «git push» asked me for username and password and this time it worked.

Peter Mortensen's user avatar

answered Nov 26, 2013 at 7:03

Bartosz's user avatar

BartoszBartosz

932 silver badges5 bronze badges

1

If you have enabled the two-factor authentication on your GitHub account, then sign in to your GitHub account and go to

New personal access token

to generate a new access token, copy that token, and paste as a password for authentication in the terminal.

Peter Mortensen's user avatar

answered May 10, 2018 at 16:33

RegarBoy's user avatar

RegarBoyRegarBoy

3,2661 gold badge23 silver badges44 bronze badges

I started experiencing this issue on Visual Studio Code in Ubuntu 20.04 yesterday.

I did not make any changes to my GitHub credentials, neither did I change anything in the project, but I run any git command to communicate with my remote branch like:

git pull origin dev

I get the error below:

remote: Repository not found.
fatal: Authentication failed for ‘https://github.com/MyUsername/my-project.git/’

Here’s what worked for me:

I tried recloning the project and then running the git pull command but it did not work.

git clone https://my-git-url

I tried setting my credentials again using the below commands but still no luck:

git config --global user.email "email@example.com"
git config --global user.name "John King"

I tried removing the remote repository and re-adding it using the below commands, but still no luck:

git remote remove origin
git remote add origin https://my-git-url

Finally, I decided to try using my default Ubuntu terminal and it worked fine. My big guess is that it’s a bug from Visual Studio Code from the last update that was made some few hours before then (See the screenshot that shows that a Release was done on the same day that I was having the issue). I mean I set up Visual Studio Code using snap, so probably it might have been updated in the background a few hours before then.

enter image description here

Hopefully, they will get it fixed and git remote operations will be fine again.

answered Nov 13, 2021 at 10:15

Promise Preston's user avatar

Promise PrestonPromise Preston

24.5k12 gold badges146 silver badges144 bronze badges

2

Just from your .config file change:

url = http://www.github.com/###user###/Random-Python-Tests

To:

url = http://###user###@github.com/###user###/Random-Python-Tests

Peter Mortensen's user avatar

answered Jul 7, 2016 at 15:25

ccamacho's user avatar

ccamachoccamacho

7078 silver badges22 bronze badges

0

Got the above error message when I updated my computer password.
Reset my git credentials using the following steps:

Go to Control Panel > User Accounts > Credential Manager > Windows Credentials. You will see Git credentials in the list (e.g. git:https://). Click on it, update the password, and execute git pull/push command from your Git bash and it won’t throw any more error messages.

answered May 18, 2021 at 11:02

Marilynn's user avatar

1

If you are on Windows and trying to push to a Windows server which has domain users working as repository users (TFS), try getting into the TFS URL (i.e. http:\\tfs) with Internet Explorer. Enter your domain account credentials and let the page appear.

Caution: Only use Internet Explorer! Other browsers won’t change your system credentials.

Now go to Git Bash and change your remote user for the repository like below:

git config user.name "domainName\userName"

And done. Now you can push!

Peter Mortensen's user avatar

answered Jul 5, 2018 at 9:13

AmiNadimi's user avatar

AmiNadimiAmiNadimi

5,1693 gold badges39 silver badges55 bronze badges

I was getting below error when trying to push to github remote

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Solution
SSH Keys were missing on github account

  1. Copy local public ssh keys from ~/.ssh directory

  2. Paste to Github > Settings > SSH and GPG Keys > New SSH Key

  3. Try ssh -T git@github.com
    This should output

    Hi xxxxx! You’ve successfully authenticated, but GitHub does not provide shell
    access.

answered Aug 12, 2021 at 9:34

Alpesh Patil's user avatar

Alpesh PatilAlpesh Patil

1,67012 silver badges15 bronze badges

2

For me, I forgot that I had changed the password on github.com, and my keychain for shell authentication never updated to that new password.

Deleting everything Git from my keychain and then rerunning the Git request helped solve the issue, prompting me again for the new password.

Peter Mortensen's user avatar

answered Nov 5, 2016 at 17:22

MMMdata's user avatar

MMMdataMMMdata

8178 silver badges19 bronze badges

If you are using SSH and cloned with HTTPS, this will not work.

Clone with SSH and then push and pulls should work as expected!

Peter Mortensen's user avatar

answered Aug 23, 2018 at 23:31

GoldenWest's user avatar

GoldenWestGoldenWest

2812 gold badges4 silver badges16 bronze badges

the quick GUI way of doing is:

  1. Firstly generate an access token via create app access token.
  2. then goto sourceTree’s Settings(placed under the close button of the Source tree)
  3. A prompt will appear named «Repository Settings».
  4. There add/edit your repository path with https://USER_NAME:ACCESS_TOKEN@bitbucket.org/REPO_NAME/PROJECT_NAME.git

or for github account

https://username:access-token@github.com/username/repo.git

Here the only change to mention is adding the additional accessToken generated by the above shared create app access token link into existing path url.

answered Mar 23, 2022 at 10:19

Muahmmad Tayyib's user avatar

1

The question was asked way before Two-Factor Authentication was introduced by GitHub, however, many people are encountering this error ever since GitHub introduced 2FA.

GitHub asks for authentication every time you try to push, if you want to avoid getting prompted repeatedly, you should use github-cli which is very lightweight and you can install with apt, yum, dnf and pacman.

after installing github-cli,

  1. Type this command
gh auth login
  1. Select the account type to authenticate
  2. Select HTTPS or SSH (as desired)
  3. Login with a web browser or authenticate with access tokens as per your ease.

Access tokens can be generated from GitHub > Settings > Developer-settings > Generate Access token, copy the token, and paste it into the terminal, It is a one-time code so ensure that you do not lose the code before authenticating it on the terminal

answered Jan 15 at 11:59

Syed M Abbas Haider Taqvi's user avatar

1

In Sourcetree Go to Tools -> Options -> Authentication

On Your Email Id click on Edit and click on Refresh OAuth Token.

answered Feb 24 at 6:56

Deepali Maniyar's user avatar

Just to chime in here, what fixed the issue for me was I simply canceled out of the initial prompt, the SSH one opened up with my Bitbucket account, I entered the password there and everything worked as expected.

Peter Mortensen's user avatar

answered Mar 26, 2017 at 18:36

Trevor Hart's user avatar

Trevor HartTrevor Hart

9937 silver badges26 bronze badges

thumb

После включения двухфакторной аутентификации в моей учётной записи GitHub, когда Я запускаю команду Git git push она выдаёт следующее сообщение об ошибке:

$ git push
Username for 'https://github.com': Username
Password for 'https://Username@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/username/repository.git/'

Что вызывает эту ошибку

Это сообщение об ошибке говорит само за себя. Это означает то, что мы пытаемся использовать неверное имя пользователя или пароль. Но Я уверен в том, что использую правильное имя пользователя и пароль. В моём случае, это произошло со мной после того, как Я включил двухфакторную аутентификацию (2FA) в моём аккаунте GitHub. Поэтому я знаю о том, что вызвало это сообщение об ошибке.

Как это решить

Как только мы узнали о том, что вызывает сбой работы git, мы можем использовать это для решения проблемы. Это действительно простой процесс. Для того, чтобы решить эту проблему, нам нужно всего лишь создать личный token доступа GitHub и использовать его вместо нашего пароля GitHub и двухфакторного кода аутентификации. Теперь пошаговое руководство.


Создание token доступа к персональному доступу GitHub.

В правом верхнем углу любой страницы нажмите на фотографию своего профиля, затем нажмите Settings.

В левой боковой панели нажмите Developer settings.

В левой боковой панели нажмите Personal access tokens.

Нажмите Generate new token.

Дайте вашему token имя (любое имя описывающее цель его создания).

Выберите области действия или разрешения, которые вы хотите предоставить этому token. Для того, чтобы использовать ваш token для доступа к репозиториям из командной строки, выберите repo.

Нажмите Generate token.

Скопируйте token в буфер обмена. По соображениям безопасности, после ухода со страницы, вы не сможете снова увидеть token.

Как исправить: fatal: Authentication failed for https://github.com/

Примечание! Относитесь к своим token’ам, как к паролям и держите их в тайне (если вы не хотите, чтобы другие люди использовали API от вашего имени). При работе с API, используйте token’ы как переменные окружения вместо hardcoding их в ваши программы.


Использование token в командной строке.

Как только у нас появился token, мы можем ввести его вместо нашего пароля при выполнении операций Git через HTTPS. Просто введите свой token после запроса пароля, а затем смотрите на то, как происходит магия…

Username: your_username
Password: your_token

Примечание! Token’ы личного доступа могут использоваться только для операций HTTPS Git. Если ваш репозиторий использует удалённый URL SSH, вам нужно будет переключить управление с SSH на HTTPS.

Примечание! Если вам не будет предложено ввести имя пользователя и пароль, ваши учетные данные могут быть кэшированы на вашем компьютере. Вы можете обновить свои учетные данные в Keychain заменить старый пароль на token.

Заключение

Вот и всё, готово. Теперь проблема возникшая после включения двухфакторной аутентификации в учётной записи GitHub устранена. Так просто, не так ли?

Если у вас возникают проблемы в устранении этой проблемы с помощью приведенной выше инструкции, но вы смогли решить эту проблему любым другим способом, пожалуйста, опишите его в разделе комментариев ниже. Спасибо!

Я надеюсь, что эта статья помогла вам узнать, как решить проблему которая возникла после включения двухфакторной аутентификации в учётной записи GitHub. Если эта статья помогла вам решить проблему, пожалуйста, оставьте комментарий :smiley:

Спасибо за прочтение!

I’ve recently begun a new web project and am using Git.

I’ve had success cloning, adding, committing, pushing, you know the basics.
I was digging through docs on bypassing the credential step and I fear this is where the problem lies.

I had attempted this last week and I don’t have details on what I had done unfortunately.

The error I’m experiencing is…

$ git push
Password for 'https://=@github.com':

When I enter the password, it returns a

fatal: Authentication failed

I’ve only ever used one password so I’m sure it’s not a mismatch.

I’ve tried unsetting credential helpers with no luck already.
I’ve also tried wiping out the GIT tracking and recloning the repo, so my gut reaction is it’s a global settings problem.

What stuck out to me was the https://=@
I’m unclear to exactly what this path refers to though.

# ~/.gitconfig

[user]
    name = Joe Hillman
[gui]
    recentrepo = C:/Users/Joe/sandbox
    recentrepo = C:/Users/Joe/Projects/Scripting Projects
[credential] username = =

My email matched with the site so I went ahead and pulled it.
Credential settings stick out to me though being empty.
That may have been what I was mucking around with last week.

$ git remote -v

origin  https://github.com/littleredplanedesign/camareroFramework.git (fetch)
origin  https://github.com/littleredplanedesign/camareroFramework.git (push)

Apparently this problem was the blank credential area in the config.

I’m back up and running. Thanks for the assist on this as I wouldn’t have guessed to check this file initially. I was looking at another config entirely.

Git is a popular version control software that every developer should know how to use. But sometimes, it pops out strange errors that confuses even seasoned users. If you are seeing “Authentication failed” whenever you try to use git push command, this short article is going to help you solve this error message.

The “fatal: Authentication failed” error message indicates that the existing authentication method you have been using on your repository has become obsolete/outdated. The full error message may look like this

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/user/example-project.git/'Code language: JavaScript (javascript)

Or if you’re pushing to your remote repository via HTTPS, the error message may look like this

If you enabled two-factor authentication in your Github account you won't be able to push via HTTPS using your accounts password. Instead you need to generate a personal access token. This can be done in the application settings of your Github account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.

Usually, the “Authentication Failed” error happens if you recently enabled 2-Factor Authentication on your GitHub account and uses HTTPS to push/pull in Git at the same time. GitHub deprecates the password authentication method from August 13, 2021 to favor more secure way of authentication. In this article, we will show you several possible ways to get around the “fatal: Authentication failed” problem.

Switch to SSH protocol in Git

As being said earlier, Github is no longer allow authenticating via HTTPS URLs once 2-Factor Authentication (2FA) enabled. Git with HTTPS uses public-key encryption-based authentication for doing every action like git push, git clone, git fetch and git pull, etc. Meanwhile, SSH protocol allows Git to securely transfer repository data over the internet.

In order to quickly fix “fatal: Authentication failed”, you can remove the existing origin (which is something like https://github.com:user/repo.git) and re-add a [email protected]:user/repo.git URL to instruct Git to use SSH instead. Run the following command to do so:

git remote -v
git remote remove origin
git remote add origin [email protected]:user/repo.git

If you didn’t set up the necessary private keys for Git, running the commands above will end up with an error message. You may need to consult access Github repositories using SSH keys and Connecting to GitHub with SSH for instructions on adding private keys.

git remote add origin with SSH

Create a PAT (Personal Access Token)

When you connect to a GitHub repository from Git, you’ll need to authenticate with GitHub using either HTTPS or SSH. Alternatively, you can use Github CLI with the command gh auth login. All of these authentication method requires a PAT (Personal Access Token) that is a more secure alternative to passwords. Follow the instructions below to create a PAT :

First, login to your account. In the upper right corner of the page, look for your avatar, click it and select Settings.

In the Settings page, choose Developer settings > Developer settings > Personal access tokens in the left sidebar.

Personal access tokens

Click Generate new token in order to create a new PAT. You will be able to name the token, set its expiration date and its scope. For a token that specifically for managing repositories, you should limit the scope to repo.

Limit PAT scope

Finally, click Generate token. You would be redirected to another page which shows you the newly created token. Remember that the token will only be shown once. If you lost the token, you have no way to recover it but to re-generate a new one.

Treat your tokens like passwords and keep them in a secure place. The token should be stored in an environment variable instead of hardcoding them into your programs/applications source code.

Once you’re done creating a token, you have to reset the old password authentication by running the following command.

git config --global --unset credential.helperCode language: PHP (php)

You may also need to update your repository to change the protocol from HTTPS to native SSH

git remote -v
git remote remove origin
git remote add origin [email protected]:user/repo.git

Disable Github 2-Factor Authentication

If you recently enabled 2-Factor Authentication(2FA) on your GitHub account right before the “Authentication Failed” error pops up, you can try disabling it to quickly fix the problem.

However, remember that disabling 2FA significantly increase the risk of your account to be compromised. Also, If you’re a member, billing manager, or outside collaborator to a public repository of an organization that requires two-factor authentication and you disable 2FA, you’ll be automatically removed from the organization, and you’ll lose your access to their repositories. In order to regain access to the organization, you have to re-enable 2FA and re-apply to the organization.

To disable 2FA for an account, you need to log into it, then click your profile photo in the upper right corner and select Settings.

Settings icon in the user bar

Then, select Account Security in the left sidebar and click Disable in Two-factor authentication section.

Disable two-factor authentication button Github

Remove saved credentials on Windows

Windows users may beed to change your login or password of the Git service account stored in Windows Credential Manager.

First, you need to search for Windows Credential Manager from the Start menu. Usually it is placed in Control Panel if you use Windows 7 and Settings on newer Windows versions.

On the Credential Manager window, click on Windows Credentials tab and look for anything that starts with git: or ada:. In order to remove them, you would have to click each of them to open the details view and click Remove.

You may also need to remove them from Generic Credentials, too.

Remove saved credentials from Windows Credential Manager

We hope that the information above helps you solve the “fatal: Authentication failed” error message in Git. You may want to check out our other guide on fixing other popular Git issues such as Git : how to accept all current/incoming changes, How to clone a private repository in Github or How to access GitHub from inside China.

This article focuses on discussing how to solve git error (remote: Invalid username or password / fatal: Authentication failed). The approach will be to create a dummy example project file and upload it to the Git Repository properly without the following error.

Prerequisites: Git Repository, GitBash, Git Clone

Step By Step Solution

Step 1: Creating git repository and installing GitBash

You will first create a git repository where you will be pushing all your project files. And for that, you need to be installed with GitBash too (How to Install Gitbash and How to Work and Push Code on Git Repository?)

Once you are familiar with the above things, you can now move ahead with the article which will be focusing on the git error (remote: Invalid username or password / fatal: Authentication failed).

Step 2: For demonstration purposes, we have created a dummy git repository that looks something like the image attached below.

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 gonna upload to the GitHub repository.

DEMO FILES

DEMO FILES

Step 3: Checking whether GitBash has been installed on our machine successfully or not.

Checking GitBash

Checking GitBash

Step 4: Once Steps 2 and 3 is been done

If while doing step 2 i.e. following the quick setup tutorial or the article which is attached in step 1 on how git works, if you are prompted with the error (remote: Invalid username or password / fatal: Authentication failed) i.e. as shown in the image attached below. Then this article is gonna focus on that error only.

error

error

Step 5: Solve the error

A) Go to settings in your Github account >> Developer settings >> Personal access token >> Tokens (classic) >> Generate new token. See the images attached below for a better understanding.

A) 1

A) 2

A) 3

A) 4

For generating tokens you can follow up on this article (How to Create GitHub Personal Access Token).

B) Once you are ready with the token go again to your GitBash terminal and execute the push command. You will be redirected to a popup as shown in the image below:

POPUP

POPUP

C) Next, here in the pop-up tab you can:

  1. Simply copy and paste the token which you have generated just now.
  2. Or, you can go ahead and click on Sign in with your browser.

Once that is done you have finally reached your destination, you will be redirected to a new page saying, see the image below.

Succeded

Succeeded

Once this is done close the tab and go to GitBash again and you will see the error is been solved and all the files must be uploaded successfully.

UPLOADED successfully

UPLOADED Successfully

You can also visit the GitHub repository and see your files have been uploaded successfully without the error (remote: Invalid username or password / fatal: Authentication failed).

Verifying by visiting GitHub repo (UPLOADED successfully)

Verifying by visiting the GitHub repo (UPLOADED successfully)

In this way, you can add your Project files to the GitHub repository without the git error i.e. (remote: Invalid username or password / fatal: Authentication failed).

Last Updated :
07 Feb, 2023

Like Article

Save Article

Понравилась статья? Поделить с друзьями:
  • Git push u origin master выдает ошибку
  • Git push u origin main ошибка
  • Git clone ошибка авторизации
  • Git add ошибка
  • Git 503 ошибка