0

我有一个脚本如下推送到我的仓库:

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

最近,在我输入凭据后,它在最后一步开始出现以下错误:

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

所以我去创建了一个 PAT,我什至安装了 GCM Core。但是当我回来并尝试使用我的新访问令牌再次执行最后一步时,如下所示:

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

我得到以下信息:

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

如果我试试这个:

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

我明白了:

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

我试过了:

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

这再次给了我正常的密码提示

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

给我:

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

我试图使这项工作的其他一些事情:

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

这给了我:

fatal: remote origin already exists.

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

这给了我:

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

有人知道我在这里做错了什么吗?

4

1 回答 1

0

好的,回来回答我自己的问题。我的问题是我还没有正确设置凭证存储。下面的文档对我进行了排序,现在我终于可以使用 PAT 再次推送了。一旦正确设置,就不需要对我的原始脚本进行任何更改。

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

于 2021-08-23T23:40:42.897 回答