Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
578 views
in Technique[技术] by (71.8m points)

git - 简单的方法来提取所有git子模块的最新信息(Easy way to pull latest of all git submodules)

We're using git submodules to manage a couple of large projects that have dependencies on many other libraries we've developed.

(我们正在使用git子模块来管理几个依赖于我们开发的其他许多库的大型项目。)

Each library is a separate repo brought into the dependent project as a submodule.

(每个库都是作为子模块带入相关项目的单独的存储库。)

During development, we often want to just go grab the latest version of every dependent submodule.

(在开发过程中,我们通常只想获取每个依赖子模块的最新版本。)

Does git have a built in command to do this?

(git有内置命令可以做到这一点吗?)

If not, how about a Windows batch file or similar that can do it?

(如果不是,那么可以执行Windows批处理文件或类似文件?)

  ask by Brad Robinson translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

(如果这是您第一次签出--init需要先使用--init :)

git submodule update --init --recursive

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

(对于git 1.8.2或更高--remote ,添加了--remote选项以支持更新到远程分支的最新提示:)

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).

(这具有.gitmodules.git/config文件中指定的任何“非默认”分支的附加好处(如果碰巧有任何分支,默认为origin / master,在这种情况下,此处的其他一些答案也可以作为好)。)

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

(对于git 1.7.3或更高版本,您可以使用(但是有关更新的以下陷阱仍然适用):)

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.

(如果您想将子模块拉到最新版本,例如仓库指向的内容。)

See git-submodule(1) for details

(详见git-submodule(1))


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...