1

After running the following commands:

git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/<UserName>/<repo-name>.git/
git push -u origin master
Username for 'https://github.com': <User-Name>
Password for 'https://<User-Name>@github.com':

after entering the correct credentials, im getting the following error:

remote: Anonymous access to <UserName>/<repo-name>.git denied. 
fatal:  Authentication failed for 'https://github.com/<UserName>/<repo-
name>.git/'

any ideas why this happens and how to deal with it?

Omri Shneor
  • 785
  • 2
  • 12
  • 30
  • Does the username when you inputting for credential same as the username in `https://github.com//.git`? If not, do you have permission to access to the github repo? – Marina Liu May 15 '18 at 07:34

1 Answers1

1

Check if you don't have a credential helper which could overwrite your login/password:

git config credential.helper

And try the same remote URL withou a final '/'

git remote set-url origin  https://github.com/<UserName>/<repo-name>.git
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • after running: git config credential.helper im getting: wincred, what does it mean? – Omri Shneor May 12 '18 at 10:16
  • @OmriShneor it means your Git is too old: make sure to use the latest https://github.com/git-for-windows/git/releases, and use manager as a crednetial helper: type `git config --global credential.helper manager` – VonC May 12 '18 at 10:17
  • the git config --global credential.helper manager, didnt help. Ill re-install git, hopefully that will work. thanks! – Omri Shneor May 12 '18 at 10:28
  • @OmriShneor What is you version of Git? – VonC May 12 '18 at 10:29
  • git version 2.16.1.windows.4 – Omri Shneor May 12 '18 at 10:29
  • Can you update to 2.17, and make sure the helper is manager? Can you also open the Windows credential helper and delete any github.com entry? Then enxt push should ask you for your credentials once, and cache them. – VonC May 12 '18 at 10:30
  • @OmriShneor See https://stackoverflow.com/a/39608906/6309 as an example – VonC May 12 '18 at 10:32
  • 1
    Ther's no github credentials in the Windows credential manager, and im currently unable to reinstall git(work computer and work remote regulations :\ ) im prompted every time for the credentials and im entering the correct one's all the time... – Omri Shneor May 12 '18 at 10:33