解決每次git pull需要輸入用戶名密碼的問題
問題描述
在服務器上每次執行git pull,都提示輸入用戶名和密碼
現象分析
我們在git clone工程時有2中形式 https
和git@git
。當你使用前者拉取工程時每次都需要輸入用戶名和密碼
解決方案
1.執行下面命令
git config --global credential.helper store
這個時候~/.gitconfig文件中會多一行
[credential]
helper = store
2.執行git pull再次輸入用戶名和密碼
此時你會看到/root/.git-credentials
中會多一行內容。裏面的內容類似https://{username}:{password}@github.com
這種形式