通過 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://<access_token>@github.com/xx.git

例如:
git clone https://[email protected]/username/projectName.git
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章