git-subrepo
git-subrepo copied to clipboard
git subrepo push fails with Can't commit: '<mysubrepodir>' doesn't contain upstream HEAD: even after clean pull
This is my scenario:
I have a repo named testFeatures
that has only a master
branch. This repo gets updated by a process happening in JIRA. Nobody directly works on this repo. I have another repo myproduct
which is my product source code repo. I added testFeatures
as a subrepo to the myproduct
repo
git subrepo clone [email protected]:rdasan/testfeatures.git test/Features
Then i pushed changes back up the myproduct
repo. Now all my subrepo content is available in the myproduct
for other devs to use.
The testFeatures
repo keeps getting updated by the JIRA processes
Later when i work on a feature branch on the myproduct
repo, i do this:
git subrepo pull test/Features -vd
That gives me this error:
>>> git rev-parse --verify HEAD
* Assert that working copy is clean: /Users/rdasan/ExtGitHub/AegisToDo
* Check for worktree with branch subrepo/test/Features
git-subrepo: There is already a worktree with branch subrepo/test/Features.
Use the --force flag to override this check or perform a subrepo clean
to remove the worktree.
So i do this:
git subrepo clean test/Features -vd
followed by:
git subrepo pull test/Features -vd
That pulls down the latest changes from the testFeatures
repo
I make some changes to the files in the subrepo within the myProduct
repo. I also add some new files to the subrepo folder. Now i need to push these changes back upto the testFeatures
repo. So i do this:
git subrepo push test/Features -vd
The push fails with this error:
git-subrepo: Can't commit: 'subrepo/test/Features' doesn't contain upstream HEAD:
Verbose:
>>> git rev-parse --verify HEAD
* Assert that working copy is clean: /Users/rdasan/ExtGitHub/AegisToDo
* Check for worktree with branch subrepo/test/Features
* Fetch the upstream: [email protected]:rdasan/testfeatures.git (master).
>>> git fetch --no-tags --quiet [email protected]:rdasan/testfeatures.git master
* Get the upstream subrepo HEAD commit.
>>> git rev-parse FETCH_HEAD^0
* Create ref 'refs/subrepo/test/Features/fetch'.
>>> git update-ref refs/subrepo/test/Features/fetch 8fd824730406de7fbda02e22e2ddfcef3a4fadc8
* Check upstream head against .gitrepo commit.
* Deleting old 'subrepo/test/Features' branch.
* Remove worktree:
>>> git branch -D subrepo/test/Features
* Create subrepo branch 'subrepo/test/Features'.
* Check if the 'subrepo/test/Features' branch already exists.
* Subrepo parent: c2311506303bc248fe141f059fd950d417bf4e84
* Create new commits with parents into the subrepo fetch
>>> git rev-list --reverse --ancestry-path --topo-order c2311506303bc248fe141f059fd950d417bf4e84..HEAD
* Working on 41e7833f40ec0517148494ea3c7884ff2202ef91
>>> git config --blob 41e7833f40ec0517148494ea3c7884ff2202ef91:test/Features/.gitrepo subrepo.commit
* .gitrepo reference commit: 6f04778d71cdbf81316e05271e7f911c9eefbfc6
* Check for rebase
* Find parents
* Create a new commit -p 6f04778d71cdbf81316e05271e7f911c9eefbfc6
>>> git cat-file -e 41e7833f40ec0517148494ea3c7884ff2202ef91:test/Features
* Create with content
* Working on 614eb8d85cd48c96d19bd84e6c0c5373bfa86655
>>> git config --blob 614eb8d85cd48c96d19bd84e6c0c5373bfa86655:test/Features/.gitrepo subrepo.commit
* .gitrepo reference commit: 6f04778d71cdbf81316e05271e7f911c9eefbfc6
* is child: 41e7833f40ec0517148494ea3c7884ff2202ef91
* Check for rebase
* Find parents
* Create a new commit -p 4592beea7abfe7afe8c70708726c078305940b8c
>>> git cat-file -e 614eb8d85cd48c96d19bd84e6c0c5373bfa86655:test/Features
* Create with content
* Working on 9888fd1d712501dd313828405d2bcca85ae039a7
>>> git config --blob 9888fd1d712501dd313828405d2bcca85ae039a7:test/Features/.gitrepo subrepo.commit
* .gitrepo reference commit: 8fd824730406de7fbda02e22e2ddfcef3a4fadc8
* is child: 614eb8d85cd48c96d19bd84e6c0c5373bfa86655
* Check for rebase
* Find parents
* Create a new commit -p 9dd8db72a03b69614778ee54e860344f231087d5 -p 8fd824730406de7fbda02e22e2ddfcef3a4fadc8
>>> git cat-file -e 9888fd1d712501dd313828405d2bcca85ae039a7:test/Features
* Create with content
* Create branch 'subrepo/test/Features' for this new commit set c3bdbf08dc5628a45432e51d3c6dc1d82f271309.
>>> git branch subrepo/test/Features c3bdbf08dc5628a45432e51d3c6dc1d82f271309
* Remove the .gitrepo file from 6f04778d71cdbf81316e05271e7f911c9eefbfc6..subrepo/test/Features
>>> git filter-branch -f --prune-empty --tree-filter rm -f .gitrepo 6f04778d71cdbf81316e05271e7f911c9eefbfc6..subrepo/test/Features
>>> git worktree add .git/tmp/subrepo/test/Features subrepo/test/Features
* Create ref 'refs/subrepo/test/Features/branch'.
>>> git update-ref refs/subrepo/test/Features/branch 4a97aa64fa708fb893d9e9b6ad3beda884542243
* Make sure that 'subrepo/test/Features' exists.
* Check if we have something to push
* Make sure 'subrepo/test/Features' contains the 'refs/subrepo/test/Features/fetch' HEAD.
git-subrepo: Can't commit: 'subrepo/test/Features' doesn't contain upstream HEAD:
What am I doing wrong? What am I missing?
In short it means that someone/something pushed a patch into test/features since the last time you did a pull.
subrepo will only allow pushes if the HEAD of your parent repo is local. This something I have considered removing, but I haven't had time to work through the issues this might cause. See the push command documentation at https://github.com/ingydotnet/git-subrepo/blob/master/ReadMe.pod
To solve your immediate problem you need to do a git subrepo pull test/features again then push, hopefully before something else does.
I was also having this issue when there's definitely not any changes between pull
and push
. push --force
ended up making it work correctly.
i agree that --force was necessary for me even on a clean subrepo pull