Git(GitHub) 003 如何 clone 非 master 分支的代码 — 切换到指定 branch分支 或者 tag版本

来源:互联网 发布:网络同步时间在线 编辑:程序博客网 时间:2024/06/05 06:14

原博文链接:http://www.aobosir.com/blog/2016/12/25/git-how-to-clone-code-of-no-master-branch-specified-branch-tag-version/


切换到指定 branch (分支)


举例

我们的目的是:得到 https://github.com/turtlebot/turtlebot_viz 网址里面的groovy分支的源代码:

Alt text

第一步:git源代码到本地。(注意: 不是Download ZIP,它只是下载master分支的源代码,不会下载所有分支的源代码)

Alt text

git clone git@github.com:turtlebot/turtlebot_viz.git

Alt text

第二步:查看所有分支

1 . 绿色的表示本地当前分支

2 . 红色的表示远程的分支。

3 . origin/HEAD -> origin/hydro 指:远程库的当前分支是hydro

Alt text

git branch -a

Alt text

第三步:切换到指定分支,比如groovy

git checkout groovy

切换到指定 tag (版本)

举例

我们的目的是:得到 https://github.com/ros-drivers/freenect_stack 网址里面 freenect-stack-0.2.2 版本。

Alt text

克隆

git clone git@github.com:ros-drivers/freenect_stack.git

Alt text

cd freenect_stackgit tag

Alt text

git checkout freenect-stack-0.2.2

Alt text


总结:其实tag和 branch是一样的操作。

如果你感觉使用git clone XXX 下载源代码的速度太慢了,你可以参考这篇博客来配置你的git,让它提速。


参考网站:

  • https://gaohaoyang.github.io/2016/07/07/git-clone-not-master-branch/
  • http://www.jianshu.com/p/79cdb8d514ed

请访问:http://www.aobosir.com/

0 0
原创粉丝点击