Recursive Git push/pull?

☆樱花仙子☆ 提交于 2019-12-02 20:29:52

if you are talking about submodules, see cupcakes answer.

if you are talking about some folder hierarchy containing git repos, you can checkout clustergit, a tool i programmed: https://github.com/mnagel/clustergit

I find myself in the same situation whenever I want to update my llvm/clang repositories and with a bit of bash help I can 'git pull' each of them like this:

$> for dir in $(find . -name ".git"); do cd ${dir%/*}; git pull ; cd -; done

This will 'git pull' all git repos found under your current directory, and probably wont work if they are bare repositories.

Not quite git pull, but close:

git fetch --recurse-submodules

From the Git docs:

--recurse-submodules[=yes|on-demand|no]

This option controls if and under what conditions new commits of populated submodules should be fetched too. It can be used as a boolean option to completely disable recursion when set to no or to unconditionally recurse into all populated submodules when set to yes, which is the default when this option is used without any value. Use on-demand to only recurse into a populated submodule when the superproject retrieves a commit that updates the submodule’s reference to a commit that isn’t already in the local submodule clone.

I've just write a script to execute recursively on multiple git repositories. You can grab it from here:

https://github.com/DariuszOstolski/rgit

The idea is exactly the same as in clustergit but implementation differs.

I needed this a while back and made a cli available through npm. https://github.com/kenglxn/gitr/blob/master/README.md

Just do "npm install -g gitr" and then you can do any git command recursively by using gitr.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!