git 使用 access token
-
申请token
-
在
.git/config
文件中修改
修改前:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://github.com/<username>/proj.git
fetch = +refs/heads/*:refs/remotes/origin/*
修改后:
[user]
name = <username>
email = <email>
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://<username>:<access token>@github.com/<username>/proj.git
fetch = +refs/heads/*:refs/remotes/origin/*
不需要换提交人的话,可以把[user]
去掉
使用token去clone私有仓库:
git clone https://oauth2:<token>@github.com/<username>/proj.git