GitHub使用
从代码库下载代码到本地 http://bach-dream.iteye.com/blog/1333278
http://blog.csdn.net/feiniao1221/article/details/7516421
以gerrit-trigger-plugin为例,下面的链接都是从相应页面上直接拷贝的。
法一:不用github的账号,打开这个库在github上的主页,运行下面命令即可
read only
运行命令$git clone https://github.com/jenkinsci/gerrit-trigger-plugin.git
下面的三种方法都要先在github上注册账户,然后生成相应的ssh key,并把public key添加到个人账户里面,详见github帮助
read+write
$git clone git@github.com:flyingbird1221/gerrit-trigger-plugin.git
read+write
$git clone https://flyingbird1221@github.com/flyingbird1221/gerrit-trigger-plugin.git
会提示输入密码,注意此处的密码不是你在github上账户的密码,而是当前登录系统用户的密码。
read only
$git clone git://github.com/flyingbird1221/gerrit-trigger-plugin.git
http://www.cnblogs.com/yaoshan/archive/2013/01/10/2854281.html
git clone 命令参数:
usage: git clone [options] [–] <repo> [<dir>]
-v, –verbose be more verbose
-q, –quiet be more quiet
–progress force progress reporting
-n, –no-checkout don’t create a checkout
–bare create a bare repository
–mirror create a mirror repository (implies bare)
-l, –local to clone from a local repository
–no-hardlinks don’t use local hardlinks, always copy
-s, –shared setup as shared repository
–recursive initialize submodules in the clone
–recurse-submodules initialize submodules in the clone
–template <template-directory>
directory from which templates will be used
–reference <repo> reference repository
-o, –origin <name> use <name> instead of ‘origin’ to track upstream
-b, –branch <branch>
checkout <branch> instead of the remote’s HEAD
-u, –upload-pack <path>
path to git-upload-pack on the remote
–depth <depth> create a shallow clone of that depth
–separate-git-dir <gitdir>
separate git dir from working tree
-c, –config <key=value>
set config inside the new repository
参数挺多,但常用的就几个:
1. 最简单直接的命令
git clone xxx.git
2. 如果想clone到指定目录
git clone xxx.git “指定目录”
3. clone时创建新的分支替代默认Origin HEAD(master)
git clone -b [new_branch_name] xxx.git
4. clone 远程分支
git clone 命令默认的只会建立master分支,如果你想clone指定的某一远程分支(如:dev)的话,可以如下:
A. 查看所有分支(包括隐藏的) git branch -a 显示所有分支,如:
* master
remotes/origin/HEAD -> origin/master
remotes/origin/dev
remotes/origin/master
B. 在本地新建同名的(“dev”)分支,并切换到该分支
git checkout -t origin/dev 该命令等同于:
git checkout -b dev origin/dev