切换到指定 branch (分支)
举例
我们的目的是:得到 https://github.com/turtlebot/turtlebot_viz 网址里面的groovy分支的源代码:

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

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

第二步:查看所有分支
1 . 绿色的表示本地当前分支
2 . 红色的表示远程的分支。
3 .
origin/HEAD -> origin/hydro
指:远程库的当前分支是hydro
![]()
git branch -a
- 1

第三步:切换到指定分支,比如groovy
git checkout groovy
- 1
切换到指定 tag (版本)
举例
我们的目的是:得到 https://github.com/ros-drivers/freenect_stack 网址里面 freenect-stack-0.2.2 版本。

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

cd freenect_stack
git tag
- 1
- 2

git checkout freenect-stack-0.2.2
- 1

总结:其实tag和 branch是一样的操作。
如果你感觉使用git clone XXX
下载源代码的速度太慢了,你可以参考这篇博客来配置你的git,让它提速。
参考网站:
- https://gaohaoyang.github.io/2016/07/07/git-clone-not-master-branch/
- http://www.jianshu.com/p/79cdb8d514ed
来源:oschina
链接:https://my.oschina.net/u/1777508/blog/1928299