如何在一行中的所有子模块上git clone --recursive和checkout master? [英] How do I git clone --recursive and checkout master on all submodules in a single line?

查看:515
本文介绍了如何在一行中的所有子模块上git clone --recursive和checkout master?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常喜欢这个命令来获取子模块的回购:

I really like this command to fetch a repo with submodules:

git clone git@github.com:my_user/my_repo.git --recursive

但是,子模块到达时都设置为no branch我必须在每一个人手动签出主人。有没有办法递归拉子模块,并自动将分支设置为主?

However, the submodules are all set to "no branch" when they arrive, and I have to manually checkout master on each and every one. Is there a way to recursively pull submodules and automatically set the branch to master?

推荐答案

克隆包含子模块的存储库后,以下命令将一次检出所有这些主分支:

After cloning the repository containing your submodules, the following command will checkout the master branch on all of these in one go:

git submodule foreach --recursive git checkout master

这篇关于如何在一行中的所有子模块上git clone --recursive和checkout master?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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