【问题标题】:Github personal access tokenGithub 个人访问令牌
【发布时间】:2021-08-14 13:17:29
【问题描述】:

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

[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 github token


【解决方案1】:

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

检查git config --global credential.helper 的输出:它可能缓存了另一个用户/电子邮件/密码。
如果该设置为 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 条目。

【讨论】:

  • 当我输入 git config --globa credential.helper 它输出 osxkeychain
  • 当我输入 printf "protocol=https\nhost=github.com"| git-credential-xxx 得到它说 zsh: command not found: git-credential-xxx
  • @KinzLuiz 我的意思是:用你的凭证助手的输出替换 xxx
  • 它告诉我这个 printf "protocol=https\nhost=github.com"| git-credential-oskeychain get zsh: command not found: git-credential-oskeychain(MY output was oskeychain)
  • @KinzLuiz 好的。 security delete-internet-password -l github.com 怎么样?
猜你喜欢
  • 2021-12-12
  • 2021-09-04
  • 2021-10-19
  • 2021-09-30
  • 2021-08-26
  • 2014-07-02
  • 2020-01-06
  • 2019-05-03
  • 2017-11-08
相关资源
最近更新 更多