通过 access_token 从 github clone 代码

对于 public 的代码不需要用户相关的信息就可以 clone,但是对于 private 的项目必须要有用户相关信息才可以 clone 或者 pull,在一些脚本中也不可能把用户名密码写进去,所以就有了 access_token。

获取 access_token

点击 https://github.com/settings/tokens 点击右上方的 Generate new token 按钮生成一个 token。

注意

  1. 在生成 token 的时候,需要选中 repo 选项,不然 git clone 的时候会失败。
  2. 生成的 token 需要像密码一样妥善保管,因为离开该页面,就无法在看到 token 了。

参照 : https://help.github.com/cn/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line

git 使用 access_token clone 代码

clone 命令 :

git clone https://@github.com/xx.git

例如:
git clone https://[email protected]/username/projectName.git

你可能感兴趣的:(git,git,github,access_token,token)