Issue in Brief :
I am just wondering whether git provides any options to limit the submodules while looping (ex : git submodule foreach "git pull origin master")
I need like this :
git submodule foreach --limit_from="submodule_2" --limit_to="submodule7" "git pull origin master"
Issue in Detail :
I am working on a project with 24 submodules configured, i am facing the following issues which has a serious impacts in the entire team productivity,
Since its a six member team and the development goes rigorously, We used to pull the remote 3 to four times a day,
git pull origin master && git submodule foreach "git pull origin master"
Some times
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
The above may suppress the git pull most of the time.
Example : Let us consider the git status shows the following ,
# 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)
The above git status shows : Out of 24 submodules submodule_repo_4
, submodule_repo_7
and submodule_repo_23
have modifications.
git
will throw an error if i missed to clear these changes or commit them before a git pull
.
Pain taking job :
Let us consider if i commit the modification in submodule_repo_4
and submodule_repo_7
but not the submodule_repo_23
, in this case git will update all the repository upto submodule_repo_22
and it will throw an error (Ex :local file changes will be overwritten by merge) after reaching submodule_repo_23.
So to update the submodule_repo_23 after a git reset or commit, i need to loop again the submodule from the begining say submodule_repo_1.
Do we have any option to limit the submodules inthe foreach loop like below,
git submodule foreach --limit_from='submodule_repo_20' --limit_to='submodule_repo_23' "git pull orign master"
You can except submodules you do not want to process. It means that foreach will still enter the submodule but will skip the command execution:
git submodule foreach '[ "$path" = "library/PhpExcel" ] || git status'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With