git 拉取代碼兩種方式

SSH方式

需要事先在本地生成密鑰對(公/私鑰),在git服務端配置公鑰。

git clone ssh://git@{ip地址}:{port端口}/{項目路徑..項目名}.git

eg: git clone ssh://[email protected]:2222/markix/user-service.git

HTTP 方式

  • url拼接帳號密碼方式
git clone http://{username}:{password}@{git_http_url}

eg: git clone http://markix:[email protected]:30880/markix/user-service.git

後續pull、push操作不需要再輸入密碼
缺點:url記錄着密碼明文,不安全(git config remote.origin.url 會顯示帳號密碼)

  • 手動輸入帳號密碼方式
git clone {git_http_url}

eg: git clone http://10.10.10.11:30880/markix/user-service.git
根據提示分別輸入賬號、密碼

缺點:後續pull、push操作都需要輸入手動輸入帳號密碼

  • 手動輸入帳號密碼方式 + 認證憑證緩存

使用認證憑證緩存,方便一次輸入賬號密碼,後續無需在手動輸入。
git認證憑證緩存:https://git-scm.com/docs/gitcredentials

啓用認證憑證緩存:git config --system credential.helper manager
拉取代碼: git clone https://gitee.com/markix/test.git
提示輸入賬戶密碼
在這裏插入圖片描述
一次輸入,後續pull、push無需再次輸入。而且不是明文存儲,安全。

另:
Windows管理憑據:控制面板 -> 用戶帳戶 -> 憑據管理器 -> Windows 憑據。可以編輯,刪除已有憑據。

reference:
git: ‘credential-cache’ is not a git command - Remove setting


end

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章