linux 保存git的賬號密碼


今天在弄jenkins一建發版,遇到了git下載每次都要輸入賬號密碼,所以百度一下,使用一下方法,搞定

一、通過文件方式

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

touch .git-credentials vim .git-credentials

在里面按“i”然后輸入: https://{username}:{password}@github.com 

比如 https://account:password@github.com

2. 在終端下執行

git config --global credential.helper store

3. 可以看到~/.gitconfig文件,會多了一項:

[credential]
helper = store

4.OK

 

二、通過緩存方式

要求:git版本需要>=1.7.10

git config --global credential.helper cache
# 默認緩存密碼15分鍾,可以改得更長, 比如1小時
git config --global credential.helper 'cache --timeout=3600'


免責聲明!

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



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