简单的方法来拉最新的所有git submodules [英] Easy way to pull latest of all git submodules

查看:1041
本文介绍了简单的方法来拉最新的所有git submodules的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用git子模块来管理一些依赖于我们开发的其他库的大型项目。每个库都是一个单独的回购库,作为子模块引入依赖项目。在开发过程中,我们经常想要抓住每个从属子模块的最新版本。



git是否有内置命令来执行此操作?如果不是,那么Windows批处理文件或类似的文件可以做到这一点? git 1.8.2 或高于选项 - 远程被添加以支持更新远程分支的最新提示:

  git submodule update --recursive --remote 

.gitmodules .git / config 文件中指定的任何非默认分支的附加好处(如果您碰巧有任何,默认是起源/主,在这种情况下,其他一些答案也可以工作)。



对于 git 1.7.3 或以上,你可以使用(但下面的更新仍然适用):
$ b $ pre $ git submodule update - 递归

或:

  git pull --recurse-submodules 

如果要将子模块最新的提交int注意:如果这是第一次,您签出一个回购协议,您需要使用 - init first:

  git submodule update --init --recursive 

对于较老的,git 1.6.1 或以上,可以使用类似的东西(修改为git submodule foreach git pull origin master


  p> 

请参阅 git-submodule(1)获取详细信息。

We're using git submodules to manage a couple of large projects that have dependencies on many other libraries we've developed. Each library is a separate repo brought into the dependant project as a submodule. During development, we often want to just go grab the latest version of every dependant submodule.

Does git have a built in command to do this? If not, how about a Windows batch file or similar that can do it?

解决方案

For git 1.8.2 or above the option --remote was added to support updating to latest tips of remote branches:

git submodule update --recursive --remote

This has the added benefit of respecting any "non default" branches specified in the .gitmodules or .git/config files (if you happen to have any, default is origin/master, in which case some of the other answers here would work as well).

For git 1.7.3 or above you can use (but the below gotchas around what update does still apply):

git submodule update --recursive

or:

git pull --recurse-submodules

if you want to pull your submodules to latest commits intead of what the repo points to.

Note: If that's the first time you checkout a repo you need to use --init first:

git submodule update --init --recursive

For older, git 1.6.1 or above you can use something similar to (modified to suit):

git submodule foreach git pull origin master

See git-submodule(1) for details

这篇关于简单的方法来拉最新的所有git submodules的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆