我们使用git子模块来管理一些依赖于我们开发的许多其他库的大型项目。每个库都是一个单独的repo,作为子模块引入到依赖项目中。在开发过程中,我们经常想要获取每个依赖子模块的最新版本。
如何获取所有git子模块的最新更改?
我们使用git子模块来管理一些依赖于我们开发的许多其他库的大型项目。每个库都是一个单独的repo,作为子模块引入到依赖项目中。在开发过程中,我们经常想要获取每个依赖子模块的最新版本。
如何获取所有git子模块的最新更改?
当前回答
我不知道这是从哪个版本的git开始工作的,但这就是您正在搜索的:
git submodule update --recursive
我也使用git pull来更新根存储库:
git pull && git submodule update --recursive
其他回答
我不知道这是从哪个版本的git开始工作的,但这就是您正在搜索的:
git submodule update --recursive
我也使用git pull来更新根存储库:
git pull && git submodule update --recursive
我编写了这个简单的shell脚本,对我来说很好。
#!/bin/bash
#git init
git init
#git clone repo including submodules
git clone --recurse-submodules https://github.com/username/project.git
#change directory -repo
cd project
#update the remote ie tag/commits
git submodule update --remote
#add commit
git commit -a -m "commit in submodule"
#git push
git push -u origin
编辑:
philfreo在评论中指出,需要最新版本。如果有任何嵌套子模块需要处于最新版本:
git submodule foreach --recursive git pull
-----下面的过期评论-----
这不是官方的做法吗?
git submodule update --init
我每次都用它。到目前为止没有问题。
编辑:
我刚刚发现你可以使用:
git submodule foreach --recursive git submodule update --init
这也会递归地拉取所有子模块,即依赖关系。
windows 2.6.3的Git:
git子模块更新--rebase--remote
从回购协议的顶层:
git submodule foreach git checkout develop
git submodule foreach git pull
这将切换所有分支机构以开发和拉动最新的