git 下载所有分支,默认为master
分支。
git clone [git 地址]
git branch -a 查看所有分支
git branch -a
注:绿色的表示本地当前分支;红色的表示远程的分支;q退出当前命令行
git checkout
切换分支
git checkout pcl-1.12.0
git 下载指定分支(branch)
git clone --branch [branch 名称] [git 地址] 或者 git clone --b [branch 名称] [git 地址]
git 下载指定标签(tags)
git clone --branch [tags 标签] [git 地址] 或者 git clone --b [tags 标签] [git 地址]
Git submodule update,如何更新子模块
https://blog.csdn.net/bglmmz/article/details/127755543
当主项目中用 Git 管理源代码,并且项目中用 submodule 方式引入了子模块,当子模块更新代码后,在主项目中如何更新子模块最新代码呢?
- 如果是第一次 pull 子项目代码,则执行:
git submodule init
- 然后执行:
git submodule update --remote --recursive
这个命令,只是更新子模块的 branch 和 commit id 信息,并不会 pull 新代码,所以:
- 然后,进入主项目中子项目的目录,执行:
git pull
- 后续,如果主项目所引用的子项目的 branch 发生了变化,则在第 3 步时执行:
git fetch
git checkout submodule_newBranch submodule_newBranch
git pull
另:
在第 4 步中,在 git fetch 之后,如果使用的用 jetbrain 的 IDE 工具,比如 IDEA / GoLand 等,它们会管理远程仓库,此时可以通过点击右下角的 branch 弹出窗口,来选择需要 checkout 子项目哪个分支。