linux git push pull免賬號密碼


linux

在~/下, touch創建文件 .git-credentials, 用vim編輯此文件,輸入內容格式:

touch .git-credentials

vim .git-credentials

https://{username}:{password}@github.com


2. 在終端下執行 git config --global credential.helper store
3. 可以看到~/.gitconfig文件,會多了一項:
[credential]

helper = store

 

windows

1.方法一
1.1 創建文件存儲GIT用戶名和密碼

在%HOME%目錄中,一般為C:\users\Administrator,也可以是你自己創建的系統用戶名目錄,反正都在C:\users\中。文件名為.git-credentials,由於在Window中不允許直接創建以"."開頭的文件,所以需要借助git bash進行,打開git bash客戶端,進行%HOME%目錄,然后用touch創建文件 .git-credentials, 用vim編輯此文件,輸入內容格式:

touch .git-credentials

vim .git-credentials

https://{username}:{password}@github.com

1.2 添加Git Config 內容

進入git bash終端, 輸入如下命令:

git config --global credential.helper store

執行完后查看%HOME%目錄下的.gitconfig文件,會多了一項:

[credential]

helper = store
重新開啟git bash會發現git push時不用再輸入用戶名和密碼

2.方法二
2.1 添加環境變量

在windows中添加一個HOME環境變量,變量名:HOME,變量值:%USERPROFILE%

 

2.2 創建git用戶名和密碼存儲文件

進入%HOME%目錄,新建一個名為"_netrc"的文件,文件中內容格式如下:

machine {git account name}.github.com
login your-usernmae
password your-password
重新打開git bash即可,無需再輸入用戶名和密碼


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM