Home·Error messages

git · Git

The message

fatal: Authentication failed for 'https://github.com/user/repo.git/'

What it means

The credential that was sent got rejected — it is wrong, expired, or a token without the scope this repository needs. The common trap is an expired token still cached by your credential helper: it is sent without ever prompting you, so you get the same line every time. The git credential reject line in the fix removes just that stored entry so you are asked again and can paste a fresh token. It deletes only the saved credential and touches no repository data.

The fix

printf 'protocol=https\nhost=github.com\n\n' | git credential reject
Printed by
git
Git
29

Almost every git error is a refusal that means "doing that from this state would lose something"; fatal: means git stopped without changing anything, and the hint: lines under the first line usually carry the actual remedy.

Reading an error message

  • Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
  • If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
  • Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
  • The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
  • Before pasting a fix, check what it throws away. Some of these cannot be undone.

Common questions

Q. What does “fatal: Authentication failed for 'https://github.com/user/repo.git/'” mean?

The credential that was sent got rejected — it is wrong, expired, or a token without the scope this repository needs. The common trap is an expired token still cached by your credential helper: it is sent without ever prompting you, so you get the same line every time. The git credential reject line in the fix removes just that stored entry so you are asked again and can paste a fresh token. It deletes only the saved credential and touches no repository data.

Q. How do I fix it?

printf 'protocol=https\nhost=github.com\n\n' | git credential reject — before running it, check the explanation above for what this command discards.

Q. Which tool prints this?

git. It sits under Git, and the message runs to 5 words.

Errors nearby