git命令行下每次做pull clone push操作,都要輸入用戶(hù)名和密碼,神煩,所以就有了這篇筆記。
1.在~/下, touch創(chuàng)建文件 .git-credentials, 用vim編輯此文件,輸入內(nèi)容格式:
touch .git-credentials
vim .git-credentials
# https://{username}:{password}@github.com # 注意這里直接是域名,而不是具體的項(xiàng)目git倉(cāng)庫(kù)地址 這一行可以不添加
2.在終端下執(zhí)行
git config --global credential.helper store
3. 查看~/.gitconfig文件
[credential]
helper = store
如果出現(xiàn)以上這段文字,就說(shuō)明OK了。
后續(xù)在首次git pull /push 等操作時(shí),再需要輸入用戶(hù)名和密碼,輸入之后就會(huì)自動(dòng)加入到.git-credentials文件中,就不需要多次輸入了。