Related to:
Before the git version 2.13
, everything was perfect around here, but now with this version they broke my workflow:
Push: process for submodule 'Packages/Advanced CSV' failed
D:\SublimeText\Data> git.exe push --porcelain --progress --tags --recurse-submodules=on-demand origin refs/heads/develop:refs/heads/develop
src refspec 'refs/heads/develop' must name a ref
process for submodule 'Packages/Advanced CSV' failed
I am using the Smartgit
client, and now when I hit the push button, I got this error above. Searching I found it was a new update on git client the problem:
It looks like the git push recurse-submodules behavior has changed. Currently with 2.13 you cannot run "git push --recurse-submodules=on-demand" if the parent repo is on a different branch than the sub repos, e.g. parent repo is on "develop" and sub-repo on "master".
...
I was under the impression that Jonathan and may be others considered the fact that
git push --recurse-submodules=on-demand
doesn't work as before an unintentional change. He asked me previously if pushing without a refspec will work for us and I responded with a yes. The question remains if everyone is on board with change push without refspec to usepush.default
in the parent repo as well as submodules.Cheers,
JS
git push recurse.submodules behavior changed in 2.13
I did not understand the last part without refspec to use push.default in the parent repo as well as submodules
, is it a way to git push --recurse-submodules=on-demand
when the parent repo is on the develop
branch and the submodules are on the master
branch?
If it is not, how can I do git push --recurse-submodules=on-demand
when the parent repo is on the develop
branch, but the submodules are on the master
branch with this new git version?
Update
I created this script which reproduces the problem locally with local remotes:
# Create the directory structure
rm -r -f main_repo
rm -r -f main_repo_remote
rm -r -f submodule_remote
mkdir main_repo_remote
mkdir submodule_remote
mkdir main_repo
mkdir main_repo/first_submodule
cd main_repo
# Setup the first_submodule
cd first_submodule
printf "# Submodule Repository\n\n" > README.md
git init
git add README.md
git commit -m "Added the repository first commit."
git init --bare ../../submodule_remote
git remote add origin ../../submodule_remote
git push origin master
# Setup the main_repo
cd ..
printf "# Main Repo\n\nThis is the main repository which contains submodules\n" > README.md
git init
git add README.md
git submodule add -- ../../submodule_remote "first_submodule"
git commit -m "Added the main repository first commit."
git init --bare ../main_repo_remote
git remote add origin ../main_repo_remote
git push origin master
git checkout -b develop
git push --set-upstream origin develop
# Add an unpushed commit to the submodule
cd first_submodule
printf "Dirty\n\n" >> README.md
git add README.md
git commit -m "Added the repository second commit."
# Go to the main repository and do the push
cd ..
git add first_submodule
git commit -m "Added the main repository second commit."
git push --recurse-submodules=on-demand
At its last line, I am doing the push on the main repo, but it is failing on the new git version.
Currently the solution is to manually open the submodules which need to be pushed and push them before to push the main repository, as the option --recurse-submodules=on-demand
does not work on the main repository.
This is a output example:
$ sh create_bug.sh
Initialized empty Git repository in D:/User/Downloads/test/main_repo/first_submodule/.git/
[master (root-commit) 69015bb] Added the repository first commit.
1 file changed, 2 insertions(+)
create mode 100644 README.md
Initialized empty Git repository in D:/User/Downloads/test/submodule_remote/
Counting objects: 3, done.
Writing objects: 100% (3/3), 249 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To ../../submodule_remote
* [new branch] master -> master
Initialized empty Git repository in D:/User/Downloads/test/main_repo/.git/
Adding existing repo at 'first_submodule' to the index
[master (root-commit) 6af0279] Added the main repository first commit.
3 files changed, 7 insertions(+)
create mode 100644 .gitmodules
create mode 100644 README.md
create mode 160000 first_submodule
Initialized empty Git repository in D:/User/Downloads/test/main_repo_remote/
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 430 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To ../main_repo_remote
* [new branch] master -> master
Switched to a new branch 'develop'
Total 0 (delta 0), reused 0 (delta 0)
To ../main_repo_remote
* [new branch] develop -> develop
[master 58e7111] Added the repository second commit.
1 file changed, 2 insertions(+)
[develop 69f9588] Added the main repository second commit.
1 file changed, 1 insertion(+), 1 deletion(-)
fatal: src refspec 'develop' must name a ref
fatal: process for submodule 'first_submodule' failed
fatal: The remote end hung up unexpectedly