Question or issue on macOS:
I’m just getting started with Git/Github and I’m completely stuck. I’m using Terminal on Mac/OSX El Capitan and when it asks for password it tells me it is invalid, but I am entering the same password that I created for my GitHub account, so surely this should work? What am I doing wrong?
Last login: Sun Dec 4 10:46:35 on ttys000 Seans-MBP:~ mrseanbaines$ git push -u origin master Username for 'https://github.com': mrseanbaines Password for 'https://[email protected]': remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/mrseanbaines/cartwheeling-kitten.git/' Seans-MBP:~ mrseanbaines$
How to solve this problem?
Solution no. 1:
I had faced same issue.
Solution:
Step 1: Control Panel
Step 2: Credential Manager
Step 3: Click Window Credentials
Step 4: In Generic Credential section ,there would be git url, edit and update username and password
Step 5: Restart Git Bash and try for clone
Solution no. 2:
(1) Go to https://github.com/settings/security , turn off Two-factor authentication.
(2) Create a new folder, inside the new folder:
git clone https://github.com/mrseanbaines/cartwheeling-kitten.git cd cartwheeling-kitten
Open empty source code directory, since you use macOS, type
open .
(3) Copy your source code to folder cartwheeling-kitten (it’s the opening folder)
(4) Config
git config user.name "Your full name" git config user.email "Your_email_address_what_used_to_register Github_account"
(5) Add remote URL
git remote add upstream https://github.com/mrseanbaines/cartwheeling-kitten.git
(6) Add to stage, then push
git add -A . git commit -m "Upload source code" git push -u origin master
(7) Go to https://github.com/mrseanbaines/cartwheeling-kitten see result.
Solution no. 3:
2020 – When you change your password on Github and after in your local machine it will complain about credentials but you can easily fix it doing a git pull
which will force asking you the credentials. So you type the new one and be happy :). š
Solution no. 4:
Once you have enabled 2 Factor Authentication (2FA) on GitHub, you cannot use your GitHub password on the command line. Instead, you have to use a personal access token.
Personal access tokens are used to authenticate you for personal applications and on the command line. The command line does not tell us we need to generate a personal access token, which is why this solution is often overlooked by programmers.
Navigate to the āSettingsā page
Click āDeveloper settingsā in the sidebar
Click āPersonal access tokensā in the sidebar
Click āGenerate new tokenā
Fill in the form to create a new token
Use that token as password and git clone will work work
Solution no. 5:
Make sure your remote urls are correct. It looks like you’re missing the protocol, it should be: https://github.com/mrseanbaines/cartwheeling-kitten.git
. You can verify this by cloning the repo to another directory, and trying git operations there.
If you want to fix it to add the protocol, you can do: git remote set-url origin https://github.com/mrseanbaines/cartwheeling-kitten.git
Solution no. 6:
If you already have setup SSH key in your system for some other git account then just do these steps https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
and check activation using ssh -T [email protected]
if you see ‘Hi GitAccountUserName! You’ve successfully authenticated, but GitHub does not provide shell access.’
Then continue your previous work.
Solution no. 7:
When I tried to push the code into remote repo from local (macbook), I faced the same issue after PASSWORD reset on GHE website.
$ git push -u origin coffee_shop_autorization
remote: Invalid username or password.
fatal: Authentication failed for ‘https://github.com/ravinderreddy-p/FSND.git/‘
Then I followed below simple steps to fix this issue:
-
I cloned another repository from GHE to local in different folder:
git clone https://github.com/ravinderreddy-p/bookshelf.git
- I switched to this folder by ‘cd bookshelf‘
-
I tried to push the same without making any changes as below:
git push
- It prompted for Username for ‘https://github.com‘:<Provide your GHE user name> then press enter.
- It prompted as Password for ‘https://[email protected]‘: <provide
updated password on GHE> then press enter - You will see this message as “Everything up-to-date”
All Done.
Now go to your previous local repo where you tried to push the code into remote and execute your previous command
git push -u origin coffee_shop_autorization
It will push the code into remote repo and you can see similar as below (with your repo and branch details):
Enumerating objects: 35, done.
Counting objects: 100% (27/27), done.
Delta compression using up to 4 threads
Compressing objects: 100% (14/14), done.
Writing objects: 100% (15/15), 2.47 KiB | 843.00 KiB/s, done.
Total 15 (delta 8), reused 0 (delta 0)
remote: Resolving deltas: 100% (8/8), completed with 5 local objects.
remote:
remote: Create a pull request for ‘coffee_shop_autorization’ on GitHub by visiting:
remote: https://github.com/ravinderreddy-p/FSND/pull/new/coffee_shop_autorization
remote:
To https://github.com/ravinderreddy-p/FSND.git
- [new branch] coffee_shop_autorization -> coffee_shop_autorization
Branch ‘coffee_shop_autorization’ set up to track remote branch ‘coffee_shop_autorization’ from ‘origin’.