git push免輸入帳號和密碼方法

最近在作些oj,因此須要頻繁的git push提交代碼,每次都要輸入賬號和密碼,感受不舒服,因而乎就作了以下設置,而後就能夠開心的提交啦~html

Linux或者Mac下方法:

  1. 建立文件,進入文件,輸入內容:
cd ~
touch .git-credentials
vim .git-credentials
https://{username}:{password}@github.com
  1. 在終端下輸入:
git config --global credential.helper store
  1. 打開~/.gitconfig文件,會發現多了一項:
[credential]
    helper = store

Windows方法:

  1. 方法同上面,只是第一步建立git-credentials有點不一樣。在%HOME%目錄中,通常爲C:\users\Administrator,也能夠是你本身建立的系統用戶名目錄,反正都在C:\users\中。文件名爲.git-credentials,因爲在Window中不容許直接建立以"."開頭的文件,因此須要藉助git bash進行,打開git bash客戶端,進行%HOME%目錄,而後用touch建立文件 .git-credentials, 而後後面的操做同上面。
  2. 還有一種方法參考Windows下設置git push免密碼

參考文獻:

git push時候總提示輸入帳號密碼 - 免除設置
Windows下設置git push免密碼linux

相關文章
相關標籤/搜索