天天看點

gitbash配合github使用使用說明

使用說明

使用github當做遠端庫,用gitbash做同步工作。首先需要gitbash工具、github的庫。這種同步解決方案與很多svn很類似。比如用tortoiseSVN同步代碼到伺服器是一樣的。

gitbash工具官網可以下載下傳,另外在github上建立repository,不用多說。

第一步:配置gitbash

配置一下gitbash和github的通信協定

桌面右鍵打開gitbash,

輸入

ssh-keygen -t rsa -C "[email protected]":

回車後輸入資訊,可以直接一直回車下去。然後會在C槽-使用者-xx-下有一個.ssh檔案夾

裡面有兩個内容:id_rsa 、id_rsa.pub

記事本打開id_ras.pub,複制内容

打開github賬戶配置,點選ssh配置,新增sshkey,标題随便輸入,内容粘貼到key裡面,确認儲存

在gitbash裡輸入

ssh –T [email protected]

即可驗證是否配置成功

配置gitbash的使用者名和郵箱:

git config –global user.name “使用者名”
git config –global user.email “郵箱” 

           

配置完之後,gitbash指令行後面會多一個括号,顯示master字樣

第二步:建立github repository

建立項目,輸入名稱,點選clone or download 擷取裡面的下載下傳位址

[email protected]:使用者名/庫名.git

第三步:本地與github連結

本地建立檔案夾,打開gitbash

輸入指令:

git init

初始化本地倉庫

輸入指令:

git remote add origin [email protected]:使用者名/庫名.git

遠端連接配接

輸入指令:

git pull [email protected]:使用者名/庫名.git

将github庫同步到本地來

第四步:gitbash同步常用指令

//git add->git commit->git push 
git init //初始化倉庫
git add 檔案名 //新增單個檔案 
git add . //新增全部檔案
git commit -m "備注" //送出
git status //檢視狀态
git push //送出