0

I have a script as follows to push to my repo:

cd /pathtomyrepo

git fetch origin
git merge origin/master
git add .
git status
echo -n "Enter the Description for the Change: " [Minor Update]
read CHANGE_MSG
git commit -m "${CHANGE_MSG}"
git push --force-with-lease origin master

Recently it has started giving the following error at the last step after I enter my credentials:

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.

So I went and created a PAT, I even installed GCM Core. But when I came back and tried to do the last step again with my new access token as follows:

sudo git push --force-with-lease origin master https://<myPAT>@github.com/scstraus/home-assistant-config.git

I get the following:

invalid refspec 'https://<myPAT>@github.com/scstraus/home-assistant-config.git'

If I try this:

sudo git push --force-with-lease origin master https://scstraus:<myPAT>@github.com/scstraus/home-assistant-config.git

I get this:

error: src refspec https://scstraus does not match any.

I tried:

sudo git push --force-with-lease origin master

which gave me the normal password prompt again

Username for 'https://github.com': scstraus
Password for 'https://scstraus@github.com': 
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/scstraus/home-assistant-config/'
git remote -v

gives me:

origin  https://github.com/scstraus/home-assistant-config (fetch)
origin  https://github.com/scstraus/home-assistant-config (push)

Some other things I tried to make this work:

git remote add origin https://<myPAT>@github.com/scstraus/home-assistant-config

which gave me:

fatal: remote origin already exists.

and

curl -u scstraus:myPAT https://api.github.com/scstraus

which gives me:

{
  "message": "API rate limit exceeded for user ID 7644023.",
  "documentation_url": "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"
}

Anyone know what I'm doing wrong here?

1 Answers1

0

Okay, coming back to answer my own question. My problem was that I had not yet properly set up a credential store. The below docs got me sorted and now I can finally push again using a PAT. No changes were needed to my original script once this was properly setup.

https://github.com/microsoft/Git-Credential-Manager-Core/blob/main/docs/linuxcredstores.md