GitHub配置token拉取和上傳
8月13日開始,github開始停止使用賬號密碼拉取項目。
所以13號之后使用命令操作github上項目呜袁,比如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/PeiAlan/springDemo.git/'
github的本意是想通過令牌替代賬號密碼這種不安全的操作型宝,由于是強制的,所以也只能更新令牌了捂襟。
操作如下:
一.通過github創(chuàng)建新的access token
流程如下:
1.右上角頭像->Setttings->Developer settings->Personal access tokens->Generate new token
2.日期我選擇No expiration(無限期)咬腕,授權(quán)范圍的話全部選上。
- 填寫Note葬荷,例如:ellisonpei涨共;
- 選擇Expiration,選擇無期限宠漩;
- 選擇Select scopes举反,全選。
3.點擊Generate token生成扒吁,令牌保存成功火鼻。記住,這個生成的令牌一定要保存好雕崩。
二.切換登錄方式魁索,使用最新的令牌登錄。
1.切換到git項目盼铁,使用下面的命令清空本地存儲的賬號密碼粗蔚。
git config --local credential.helper ""
2.配置新的令牌訪問。
直接用文本編輯器打開git項目根目錄中 .git/config文件捉貌。(PS:注意.git是隱藏文件夾)
按照如下格式支鸡,修改url和fetch即可:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
url = https://ellisonpei:這里填access_token@github.com/項目名/項目名.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
name = aa5279aa
email = xxxx@qq.com
[branch "develop"]
remote = origin
merge = refs/heads/develop
[credential]
helper =