git for windows (又名 msysgit)如何記住用戶名和密碼 :
先創建存儲用戶名密碼的文件 ,在home
文件夾,一般是 C:\Documents
and Settings\Administrator
下建立文件.git-credentials
(windows
下不允許直接創建以.開頭的文件,所以有一個小技巧:先創建一個文件名叫
)git-credentials
然後進入 git
bash
使用命令:
mv git-credentials .git-credentials
用記事本打開這文件輸入,如果用戶名中有@,那麼使用%代替:
https://{username}:{password}@github.com
例:https://xiaoerlang:[email protected]
保存;
進入 git bash,然後輸入:
git config –global credential.helper store
執行完後去查看 C:\Documents and Settings\Administrator\.gitconfig
這個文件,發現多了一項: [credential]
helper = store
就成功了。
然後要重開 git bash 窗口,再push就不用輸入用戶名密碼
ps:如有其他庫,如@git.oschina.net,則並列添加即可