參考:https://git-scm.com/book/zh/v2
添加遠端倉庫
$ git remote add origin [email protected]:stone927/helloworld.git
stone927:使用者名
helloworld:倉庫名
推送至遠端倉庫
$ git push -u origin master
origin master表示指定推送到分支master
-u表示将master設定為本倉庫目前分支的上遊分支,下次從共享倉庫擷取内容預設選擇master,省去了寫參數的麻煩
輸入gitHub使用者名密碼後推送資料
擷取遠端倉庫
$ git clone https://github.com/stone927/helloworld.git
clone會預設處于master分支下
檢視遠端倉庫中的分支情況
$ git branch -a
擷取遠端倉庫分支
$ git checkout -b branch-A origin/branch-A
-b表示建立分支branch-A,因為此時本地沒有分支branch-A是以需要建立,名稱和遠端倉庫中的分支名相同以防混淆;
origin/branch-A表示新建立的分支branch-A使用共享庫中的分支origin/branch-A作為擷取來源
擷取最新的遠端倉庫分支
$ git pull