在linux環境下將github上的代碼pull下來或者將本地代碼push到github上時,每次都需要輸入賬號密碼,很麻煩!有什麼方法能不輸入呢!
1.配置ssh(此處不介紹)
2.增加配置文件
- cd到根目錄下,執行git config --global credential.helper store命令
$ cd /root/ $ git config --global credential.helper store $ ll 總用量 112 ... -rw-r--r-- 1 root root 81 12月 10 14:47 .gitconfig ...
此時目錄下會增加一個.gitconfig文件,這裏面就會保存你的賬號和用戶名等信息。
-
正常push你的項目代碼或pull一次,這一次還是要求你輸入賬號和密碼的。此時根目錄下又會生成一個.git-credentials文件,這裏面就保存了你的賬號和密碼信息,可以通過cat查看
$ ll 總用量 116 ... -rw-r--r-- 1 root root 81 12月 10 15:07 .gitconfig -rw------- 1 root root 39 12月 10 14:49 .git-credentials ...
-
之後你再pull或push就不再需要輸入賬號密碼咯!
- ssh配置不成功的同學可以嘗試這種方法哦!