日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

linux下解決?git?clone每次都要輸入用戶名密碼問題(推薦)_linux shell

作者:業余敲代碼 ? 更新時間: 2022-11-23 編程語言

一、背景:

git clone代碼或者push代碼時候需要輸入賬號密碼

二、解決方法:

1、ssh方式:

先用git config --global user.name 'username’和git config --global user.email 'xxx@xxx.com’配置一下用戶名和郵箱
生成ssh公鑰:ssh-keygen -t rsa -C “xxxxx@xxxxx.com”,查看~/.ssh/id_rsa.pub文件內容,獲取到你的public key,粘貼到GitLabssh公鑰管理處即可
使用git clone http://git.gitxxx.com/xxx.git,先測試一下,看能不能拉取成功。如果成功,向下進行。此時還是會詢問用戶名和密碼的。

2、免密拉取配置

(1)cd到~/目錄下,創建一個文件:touch .git-credentials
vim .git-credentials
(2)然后輸入https://{username}:{password}@git.gitxx.com,比如http://fengjiaheng:password@git.gitxx.com
(3)然后執行:git config --global credential.helper store
(4)然后使用git config --list或者查看一下~/.gitconfig文件,會發現多了一行[credential] helper = store
(5)這時候再用 git 拉取倉庫就不需要輸入用戶名和密碼了。
注意:第4步必須要做,否則做完4、5步之后也不能免密碼拉取成功,需要再次執行第4步驟。

3、粗暴使用型

Git Clone命令直接使用用戶名密碼Clone

git clone http://userName:password@鏈接
修改為 git clone https://username:password@鏈接

示例:
git clone git@http://112.12.122.22:t-mapi/hotel-tapi.git
修改為
git clone ‘http://username:password@112.12.122.22:t-mapi/hotel-tapi.git’

注意:

(1)http -> https
(2)如果賬號username或者password中有@符號,需要 將@替換為%40
(3)如果報錯git clone event not found,需要將 git clone 后地址加上引號 ‘’

三、總結:

1、第二種方法比較簡單(推薦使用),但是第一二種方法中都首次都必須自己輸入賬號密碼
2、第三種一次都不用輸入賬號密碼(推薦使用)

原文鏈接:https://blog.csdn.net/weixin_39676449/article/details/126122939

欄目分類
最近更新