問題
最近重裝了電腦,發現每次提交代碼到遠程倉庫時都要輸入用戶名和密碼。
解決方案
GIT有兩種方式記住用戶名和密碼
-
永久記住密碼
git config --global credential.helper store
會在用戶主目錄的
.gitconfig
文件中生成下面的配置。[credential] helper = store
如果沒有
--global
,則在當前項目下的.git/config
文件中添加。當然,你還可以直接複製上面生成的配置到配置文件中。
-
臨時記住密碼
默認記住15分鐘:
git config –global credential.helper cache
下面是自定義配置記住1小時:
git config credential.helper ‘cache –timeout=3600’
不過這個我們一般是不用的。