-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:OLD_PASSWORD@github.com/projectrepo/projectname.git (fetch)
origin  https://project_username:OLD_PASSWORD@github.com/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:OLD_PASSWORD@github.com/projectrepo/projectname.git
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true


sudo git remote set-url origin https://project_username:NEW_PERSONAL_TOKEN@github.com/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
  • Thank you for your advice, I tried it and this is what I'm seeing: sudo git remote add origin https://project_username:NEW_PERSONAL_TOKEN@github.com/... sudo git remote -v origin https://project_username:OLD_PASSWORD@github.com/... (fetch) origin https://project_username:OLD_PASSWORD@github.com/... (push) origin https://project_username:NEW_PERSONAL_TOKEN@github.com/... (push) sudo git config --list user.name=project_username remote.origin.url=https://project_username:OLD_PASSWORD@github.com/... It looks to me like origin using OLD_PASSWORD is still the remote. – krfreder Jan 05 '22 at 16:11
  • Ah, so you re-create origin but the URL stays old? Do you see old values in `.git/config` file? – Stanislav Bashkyrtsev Jan 05 '22 at 16:13
  • Correct, the URL stays old. No, I actually see the new values in .git/config. – krfreder Jan 05 '22 at 16:18
  • Could you try to `--unset` those properties and re-add origin again? – Stanislav Bashkyrtsev Jan 05 '22 at 16:21
  • Also, if you use Windows, try this out: https://stackoverflow.com/questions/57947268/how-do-i-log-in-using-the-git-terminal/57947653#57947653 – Stanislav Bashkyrtsev Jan 05 '22 at 16:24
  • Thanks for your help! I realized I was making changed locally but the old URL was set globally and was able to fix it. – krfreder Jan 05 '22 at 17:21
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:NEW_PERSONAL_TOKEN@github.com/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