42

I'm facing problems while trying to pull/push my code into a GitHub repository using the cmd prompt for the last two days. How can I resolve this issue?

Logon failed, use Ctrl + C to cancel basic credential prompt. Username for 'https://github.com': satyendrasingh8 Password for 'https://satyendrasingh8@github.com': remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/satyendrasingh8/chatApp.git/'

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
satyendra singh
  • 479
  • 1
  • 4
  • 5
  • If you are here from a search engine (e.g. matching "problems while trying to pull/push my code into a GitHub repository") looking for a solution to the problems after the ***[Visual Studio Code](https://en.wikipedia.org/wiki/Visual_Studio_Code) update in November 2021*** (to version 1.62.2), then the candidate for the canonical question for that particular problem is *[fatal: Authentication failed for](https://stackoverflow.com/questions/69979522/)* (despite the unspecific title). – Peter Mortensen Nov 19 '21 at 20:32

9 Answers9

81

Fitz_Hoo is right! I just wanted to give a more detailed explanation that fix my issue. Essentially GitHub deprecated their password authentication recently (you can read more by clicking here).

Enter image description here

Now instead of adding your username/email and password, you will login with your browser. The image below is the new interface. As Fitz_hoo mentions, you must update your Git to see the new changes!

Enter image description here

If you are using Windows, you can simply use this command below to update your Git:

git update-git-for-windows
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ousecTic
  • 1,895
  • 11
  • 20
  • I updated git and cleared credentials from Windows Credential Manager but still had the problem. There turned out to be a load of [url "https://api:@github.com/"] lines in my C:\Users\\.gitconfig file. After deleting those authentication proceeded as it should: offer to authenticate via browser or to input an access token -> input access token -> up and running again. – bea Aug 17 '21 at 14:59
  • Where we need to execute the git update command? I have tried in powershell and it is not working – aadi1295 Jan 19 '22 at 14:52
31

I fixed the problem just simply by upgrading my client Git Bash to the latest version!

When I encountered the problem, I received an email from a GitHub official, who told me the reason was mainly the Git version was incompatible:

GitHub has changed how users authenticate when using Git for Windows, and now requires the use of a web browser to authenticate to GitHub. To be able to login via web browser, users need to update to the latest version of Git for Windows. You can download the latest version at:

https://gitforwindows.org/

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Fitz_Hoo
  • 581
  • 5
  • 4
2

One reason for this message could be that the remote branch you were trying to pull was already deleted.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Juanma Menendez
  • 17,253
  • 7
  • 59
  • 56
1

For me, the problem was that instead of my username I was trying to login with my email.

isherwood
  • 58,414
  • 16
  • 114
  • 157
Iraklis Bekiaris
  • 1,163
  • 15
  • 43
1

Delete the GitHub entry from Credential Manager: Control PanelUser AccountsCredential Manager.

Then push the code again.

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

I received an email from GitHub telling me

We recently updated the format of our API authentication tokens, providing additional security benefits to all our customers. In order to benefit from this new format, please regenerate your personal access token

I regenerated my personal access token (PAT) and was then unable to log in from command line on Windows 10 when I tried something like git pull.

A window would pop up, inviting me to enter 'username or email' and password. I tried various combinations, using the PAT, as mentioned in the GitHub documentation, and the actual password, but every time I received:

Logon failed, use ctrl+c to cancel basic credential prompt

Thanks to the answers from Fitz_Hoo and ousecTic, I updated my Git install with the command provided by ousecTic, and the authentication process was then completely different. You can opt to use a PAT, but when you paste it in, no characters at all are shown, so just hit Enter.

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
MikeA
  • 189
  • 9
0

In my case, I had this issue in relation to the federated authentication to AWS CodeCommit. The fix was to upgrade git to +v2.30.z (i.e. 2.35.3) and disable interactive prompt (docs):

git config --global credential.interactive false

A global configuration in ~/.gitconfig would look like:

[credential]
        interactive = false

A AWS CodeCommit specific configuration, would look like (in ~/.gitconfig):

[credential "https://git-codecommit.us-east-1.amazonaws.com"]
        interactive = false
azbarcea
  • 3,323
  • 1
  • 20
  • 25
0

For me installing the GitBash solved the problem. It allowed me to authenticate via browser option.

user115916
  • 186
  • 11
-1

here is the solution which works for me, uninstall Git from Machine after that install new version of it and sign in via web

Albert
  • 34
  • 6