首页 > 其他 > 详细

git: clone、checkout、多个 ssh key

时间:2015-08-05 13:02:04      阅读:355      评论:0      收藏:0      [点我收藏+]

如果我们从github上复制HTTPS clone URL,然后 git clone默认是checkout主分支,如果需要切换分支:

git clone https://github.com/emlid/linux-rt-rpi
git checkout [按 TAB 键]      //看到你所要的分支,然后输入就行
或者
git checkout -b [分支的名字]     //新建一个分支然后checkout

如果只需要clone某个分支(省时间可空间)则可以:

git clone -b branch_name https://github.com/emlid/linux-rt-rpi  //只克隆 branch_name这个分支
// 可以结合 --depth <depth>
//Create a shallow clone with a history truncated to the specified number of revisions.

如果需要多个管理多个仓库,分别使用不同的ssh-key。
新建ssh-key:

ssh-keygen -t rsa -f ~/.ssh/xxx_rsa -C "Key for another repo"

$HOME/.ssh目录下新建config文件,添加如下内容(默认使用 id_rsa和 id_rsa.pub, 这里新建一个使用xxx_rsa 和 xxx_rsa.pub的规则):

Host *.host_name.*
User xxx    //不用User只写Host也行
IdentityFile ~/.ssh/xxx_rsa

Host 和 User 可以根据使用clone的仓库的地址得到;ssh、git、https有点微小区别:

ssh://[user@]host.xz[:port]/path/to/repo.git/
git://host.xz[:port]/path/to/repo.git/
http[s]://host.xz[:port]/path/to/repo.git/
ftp[s]://host.xz[:port]/path/to/repo.git/
rsync://host.xz/path/to/repo.git/

版权声明:本文为博主原创文章,未经博主允许不得转载。

git: clone、checkout、多个 ssh key

原文:http://blog.csdn.net/gw569453350game/article/details/46706973

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!