I have a GitHub repository which I cloned onto my computer as a submodule of another repository.
I have all the files and commits locally, but on the remote, my git client thinks there isn't any branch. (git branch -r
shows nothing)
git fetch origin
gives this result :
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch origin
From https://github.com/Estecka/ChainMaths
* branch HEAD -> FETCH_HEAD
Completed successfully.
but in reality, I still doesn't find any branch.
Trying to push my local changes works successfully, I can see my changes reflected on the GitHub website, but even then my git client still fails to find any branch on the remote, even the one that was just pushed.
This is not the first time I've had this issue with a submodule, and I never encountered it on classical repositories.
It sounds like your submodule is configured not to fetch any refs by default. When you do a git fetch origin
without specifying anything to fetch, Git reads the remotes.origin.fetch
variable and provides that. Since you have nothing specified, Git just reads the remote HEAD
reference and stuffs it into FETCH_HEAD
, which isn't what you're looking for in this case.
If you want the standard behavior of fetching remote heads into refs/remotes/origin
, you can run git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
and then run git fetch origin
again. If you just want to do that this once, and not by default, you can run git fetch origin +refs/heads/*:refs/remotes/origin/*
.