操作步聚如下:
1: cd 回車;進入當前用戶目錄下;
2: vim .git-credentials
3:按照以下格式輸入內容:
https://{username}:{password}@github.com
其中username,password,github.com 都換成你自己的內容
4:保存退出後執行下面命令
git config --global credential.helper store
執行完後
/home/用戶名/.gitconfig 會新增一項
helper = store
或者進行如下操作:
- git bash進入你的項目目錄,輸入:
- git config --global credential.helper store
這時再執行git push/pull的時候就不會在要求你輸入密碼了。
還有一種方式就是在git clone 的時候,不用https://的形式(因爲http://是共用地址),而用git@git (ssh)的形式(因爲SSH地址含有本地的git公鑰信息,所以不再需要輸入git的用戶名和密碼)。這種方式也可以避免每次都要輸密碼。