$ git clone -b <branch> <remote_repo>
基本上有兩個作法, 一個是走不需要認證的http, 語法大概是這樣
$ git clone -b my-branch https://git@github.com/username/myproject.git
一個是走ssh, 但需要有public key認證, 語法大概是這樣
$ git clone -b my-branch git@github.com:user/myproject.git
結果ssh的出現了這樣的錯誤
Permission denied (publickey). fatal: The remote end hung up unexpectedly
爬文發現這真是newbie問題阿, github的help就有寫了, 步驟如下
1. 產生ssh keys
$ ssh-keygen -t rsa -C "your_email@example.com"
$ ssh-add id_rsa
2. 將public key提交給github 到Account Settings的"SSH Keys"中, 將public key的內容貼到key欄位
3. 測試
$ ssh -T git@github.com
如果出現這樣的訊息表示OK啦
Hi username! You've successfully authenticated, but GitHub does not # provide shell access.
reference:
* Git: clone a specific branch [duplicate]
* Generating SSH Keys