Github 个人访问令牌

Github personal access token

我刚刚发现从 13 日开始,对密码身份验证的支持被删除,取而代之的是,我应该使用个人访问令牌。我生成了令牌并按照终端提供的 link 中的步骤进行操作,但是当我尝试推送时它仍然给我一些问题。有谁知道为什么?

[kinzluiz:...ch-7-object-oriented-design]$ git status                  (main✱) 
On branch main
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
    new file:   louis/.classpath
    new file:   louis/.gitignore
    new file:   louis/.project
    new file:   louis/src/deckofcards/BlackJack.java
    new file:   louis/src/deckofcards/Card.java
    new file:   louis/src/deckofcards/Deck.java
    new file:   louis/src/deckofcards/Suit.java
    new file:   louis/src/module-info.java

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   ../ch2-linked-lists/Louis/linkedlistctci.py
    deleted:    ../ch2-linked-lists/Louis/main.py
    modified:   ../ch3-stacks-and-queues/louis/main.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    ../ch1-arraysAndStrings/Louis/.gitignore
    ../ch3-stacks-and-queues/.idea/

[kinzluiz:...ch-7-object-oriented-design]$ git commit -m "deck of cards "                                                                                                                        (main✱) 
[main e6676a6] deck of cards
 8 files changed, 103 insertions(+)
 create mode 100644 ch-7-object-oriented-design/louis/.classpath
 create mode 100644 ch-7-object-oriented-design/louis/.gitignore
 create mode 100644 ch-7-object-oriented-design/louis/.project
 create mode 100644 ch-7-object-oriented-design/louis/src/deckofcards/BlackJack.java
 create mode 100644 ch-7-object-oriented-design/louis/src/deckofcards/Card.java
 create mode 100644 ch-7-object-oriented-design/louis/src/deckofcards/Deck.java
 create mode 100644 ch-7-object-oriented-design/louis/src/deckofcards/Suit.java
 create mode 100644 ch-7-object-oriented-design/louis/src/module-info.java
[kinzluiz:...ch-7-object-oriented-design]$ git push                                                                                                                                              (main✱) 
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: unable to access 'https://github.com/AisosaUtieyin/ctci.git/': The requested URL returned error: 403

这可能意味着您的旧凭证(密码)仍存储在 Git 凭证助手中。

检查 git config --global credential.helper 的输出:它可能缓存了另一个 user/email/password。
如果该设置为 xxx,请键入:

printf "protocol=https\nhost=github.com"| git-credential-xxx get

xxx”是指“git config --global credential.helper 的输出”。
不要使用“xxx”:替换它。

您将检查是否已存储任何凭据。
如果是:

printf "protocol=https\nhost=github.com"| git-credential-xxx erase

下一次推送将提示您输入新凭据(令牌)。

例如,如果输出为:osxkeychain,请键入(仅 Mac):

printf "protocol=https\nhost=github.com"| git-credential-osxkeychain erase
# Or:
security delete-internet-password -l github.com

这两个命令都会从您的 KeyChain 中删除 github.com 条目。