-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Unable to git checkout to specific branch in git submodule #1815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Why do you need a specific branch in the submodule? Why is a detached head of a commit not sufficient? Are you then later committing changes within the submodule? |
Ok, I've stumbled upon this issue, after finding https://github.com/orgs/community/discussions/26818. My use case, if you're curiousMy use-case is that I have a brownfield mobile app (some old native code mixed with newer React Native code). The React Native code is the "host app", and then we've got the old native code in a submodule. I'm building out a "synchronized" deploy & QA pipeline involving three primary branches: main, staging, and production. One of the design goals is that:
We also have to synchronize version bumps (we want to be able to build and deploy these apps separately for now too), and we are building out the ability to cherry-pick hotfixes to the staging and production branches. As part of that, we need to do workflows like this:
The solutions are well-explained in the discussion I linked, but the kicker here is that when you do Meanwhile, if you do This workflow run illustrates the difference in a minimal reproduction. Also, I've observed that if you simply do a Next up, I'd like to look at the different commands run by
I don't really know how git is deciding the fetch refspec for submodules. If, like me, you don't want to wait for a git submodule foreach 'git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"' That will finish quickly and enable you to fetch any remote ref. If you do this, be aware that running What sucks about this solution is that I have to remember to do it any time I'm checking out a different branch in my submodule. I wonder if the maintainers would consider running |
I am trying to achieve something that I am not sure is possible. I haven't been able to find any similar cases to mine, which is why I am creating this issue. The goal is to see if anyone has encountered this before and knows how to resolve it. I wouldn't say it's a problem per se, just a request for help.
Context
My repository has two git submodules and looks like this:
My use case is a bit special because the repository is closely related to one of the git submodules. From now on, I will only mention the "git submodule" and ignore the other one since none of this concerns the other.
Basically, my workflow is triggered by pull requests, and I need to be able to clone the submodule and checkout to a branch with the same name (if a branch with the same name does not exist, master should be used).
This is how I try to checkout in the submodule:
Then after that, I need to execute some script from that submodule. The problem is I can't checkout to the branch I want (The branch exists in the origin of the git submodule repository, double-checked).
Action configuration:
The text was updated successfully, but these errors were encountered: