GIT的HTTP方式免密pull、push

注意,這裏是HTTP方式免密,不是SSH方式免密,html

SSH方式請看另外一篇博客:http://www.javashuo.com/article/p-kkuxmbzq-ch.htmllinux

 

說明:%HOME%,通常爲C:\users\Administrator,也能夠是你本身建立的系統用戶名目錄,反正都在C:\users\中git

一.windows下:github

須要建立一個.git-credentials文件,因爲在Window中不容許直接建立以"."開頭的文件,因此須要藉助git bash進行,步驟以下:vim

1.打開git bash客戶端,進入%HOME%目錄(即C:\users\本身的電腦用戶名,通常爲C:\users\Administrator)windows

2.用touch建立文件 .git-credentials。bash

3.touch建立文件後用vim打開並編輯此文件,命令以下:spa

 

打開並編輯:vim .git-credentials(i-進入編輯模式)
編輯內容:https://{username}:{password}@github.com(登陸帳號,郵箱和密碼)
保存編輯內容:按<ESC>鍵退出編輯模式,:wq  <回車>保存並退出

4.以後在執行.net

git config --global credential.helper store

打開%HOME%目錄下的.gitconfig文件,會發現多了以下內容:code

[credential]
helper = store

以上配置好後,關閉git bash從新打開,以後pull一個項目,首次仍是要輸入用戶名及密碼,以後pull成功後,再之後pull和push都不須要在輸入用戶名及密碼了,此後打開新建的.git-credentials文件發如今https://{username}:{password}@github.com之上多了一條相似的文本。

本地Windows下還能夠經過添加環境變量來配置,

參考網址:http://www.cnblogs.com/ballwql/p/3462104.html

 

 

二.Linux或者Mac下方法:

基本步驟和上面相似,就是linux下面能夠直接建立.git-credential文件,命令以下:

 

建立文件,進入文件,輸入內容:

cd ~
touch .git-credentials
vim .git-credentials
https://{username}:{password}@github.com

在終端下輸入:

git config --global credential.helper store

打開~/.gitconfig文件,會發現多了一項:

[credential]
helper = store
相關文章
相關標籤/搜索