I have a private remote repository on GitHub that I'm trying to push to production on our AWS server (using Ubuntu). I've tried the following commands and received the following errors:
sudo git pull
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/projectrepo/projectname.git/'
sudo git remote -v
origin https://project_username:[email protected]/projectrepo/projectname.git (fetch)
origin https://project_username:[email protected]/projectrepo/projectname.git (push)
sudo git remote rm origin
fatal: No such remote: 'origin'
sudo git config --list
user.name=project_username
remote.origin.url=https://project_username:[email protected]/projectrepo/projectname.git
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
sudo git remote set-url origin https://project_username:[email protected]/projectrepo/projectname.git
fatal: No such remote 'origin'
Why does Git not recognize origin and how can I correct this to update the remote.origin.url?
CodePudding user response:
You removed origin with
git remote rm origin
So no wonder it doesn't exist anymore and you can't do anything with it. You can add it back by:
git remote add origin [address]
The original error says that you shouldn't use HTTPS with Basic Auth. You should either generate a personal token and put it into URL or use ssh address (and use public-key auth):
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/projectrepo/projectname.git/'
CodePudding user response:
Figured out the answer: I realized the issue was that the remote.origin.url was set globally with OLD_PASSWORD but locally as NEW_PERSONAL_TOKEN.
This is what worked:
Using sudo git config --global --edit to edit the global config file directly.
