-1

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?

krfreder
  • 17
  • 1

2 Answers2

1

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/'
Stanislav Bashkyrtsev
  • 14,470
  • 7
  • 42
  • 45
0

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.

krfreder
  • 17
  • 1
  • Dear @krfreder, thank you for the answer. Running the `sudo git config --global --edit` did open the config file, containing user name and email tags. However, I was not sure how to proceed with `remote.origin.url`. Would it be hard for you to add an example? Much appreciated :) – Curious Watcher Apr 07 '22 at 20:01
  • 1
    @CuriousWatcher - you can find the command in my original post but I'll add it down here for you: `sudo git remote set-url origin https://project_username:[email protected]/projectrepo/projectname.git` I also found this post helpful in understanding my issue - [How do I show my global git configuration](https://stackoverflow.com/questions/12254076/how-do-i-show-my-global-git-configuration). And this documentation in understanding the `git remote` command - [Git docs, git remote](https://www.git-scm.com/docs/git-remote) – krfreder Apr 11 '22 at 16:05