Bal*_*jan 7 git version-control foreach github
问题简介:
我只是想知道git是否提供了在循环时限制子模块的任何选项(例如:git submodule foreach"git pull origin master")
我需要这样的:
git submodule foreach --limit_from="submodule_2" --limit_to="submodule7" "git pull origin master"
Run Code Online (Sandbox Code Playgroud)
问题详情:
我正在开发一个配置了24个子模块的项目,我面临以下问题,这对整个团队的生产力产生了严重影响,
由于它是一支由六人组成的团队并且开发工作非常严格,我们过去常常每天拉三到四次,
git pull origin master && git submodule foreach"git pull origin master"
有时候
1. we miss to clear/reset the repository before
2. miss to commit the changes before git pull
3. miss to checkoout the correct branch in the submodules
4. may get a auto merging conflict errors
Run Code Online (Sandbox Code Playgroud)
以上可以在大多数时间抑制git pull.
示例:让我们考虑git状态显示以下内容,
# modified: lib/library/submodule_repo_1 (new commits)
# modified: lib/library/submodule_repo_2 (new commits)
# modified: lib/library/submodule_repo_3 (new commits)
# modified: lib/library/submodule_repo_4 (new commits, modified content)
# modified: lib/library/submodule_repo_5 (new commits)
# modified: lib/library/submodule_repo_6 (new commits)
# modified: lib/library/submodule_repo_7 (new commits, modified content)
.
.
.
.
.
# modified: lib/library/submodule_repo_23 (new commits, modified content)
# modified: lib/library/submodule_repo_24 (new commits)
Run Code Online (Sandbox Code Playgroud)
上面的git状态显示:在24个子模块中submodule_repo_4
,submodule_repo_7
并submodule_repo_23
进行了修改.
git
如果我错过了清除这些更改或在之前提交它们将会抛出错误git pull
.
痛苦的工作:
让我们考虑,如果我提交的修改中submodule_repo_4
和submodule_repo_7
,但不是submodule_repo_23
在这种情况下的git将更新所有高达库submodule_repo_22
,它会抛出一个错误(例:本地文件的更改将被合并被覆盖)达到submodule_repo_23之后.
因此,为了在git重置或提交后更新submodule_repo_23,我需要再次循环来自开头说submodule_repo_1的子模块.
我们有任何选项来限制foreach循环中的子模块,如下所示,
git submodule foreach --limit_from='submodule_repo_20' --limit_to='submodule_repo_23' "git pull orign master"
Run Code Online (Sandbox Code Playgroud)
您可以排除不想处理的子模块。这意味着 foreach 仍然会进入子模块,但会跳过命令执行:
git submodule foreach '[ "$path" = "library/PhpExcel" ] || git status'
Run Code Online (Sandbox Code Playgroud)