1、在git bash命令行中輸入 ? echo $HOME ?查看git home路徑。
2、進入home對應的路徑中。
touch .git-credentials ? ?創建.git-credentials
vim .git-credentials 編輯
在./git-credentials中加入以下文本(此處文本URL可以固定寫成這樣,如果你的URL和這個不一樣,執行完以下操作之后只需要在命令行輸入一次
用戶名密碼會自動把你所使用的URL追加進去),username 和password分別代表用戶名密碼
https://username:password@github.com
git config --global credential.helper store
這是查看home路徑中的.gitconfig,會在之前
[user]
name =
**********
email=***********
的基礎上多出
[credential]
helper = stor
e
3、在命令行正常執行pull ,push,如果是在以上操作完之后第一次執行向任何URL的pull push,需要輸入一次用戶名密碼,以后不再需要輸入。
第一次向新的URL輸入用戶名密碼之后會發現 .git-credentials中追加了類似https://username:password@hello.com的內容。