We have a repo that has a few submodules. One of the submodule directories is an API. Depending on the branch of the main repo, the API subdirectory either points to API_V1 repo or API_V2 repo. If I clone the main repo, and am on develop, it points to API_V2 when I submodule init/update. But if I switch to an very old branch instead of develop, and do a submodule update or init/update git is unable to find the correct commit in the API submodule because it's still using API_V2. Is it possible to get git to change to the correct repo in the API submodule. Our devops did this to avoid having to rename the API subdir to API_V1 and API_V2, which would have needed many script changes. Thanks
GIT repo with submodule that can point to two different repositories
41 Views Asked by Larry_C At
1
There are 1 best solutions below
Related Questions in GIT
- problem to push files on a repository git
- diff3 output in git conflict style, including mergeable hunks
- Git Not In Sync with Local Branch
- Setting up the version control of .dotfiles while the .config is connected to a forked repo
- How to fix overriding the main branch in Git?
- I can't add text to "Message" in VS Code when committing to Git
- How can i redirect pull request from main branch to another branch
- Xcode commits (possibly outside of any branch) disappeared, how to get them back?
- Git/TortoiseGit : how to apply ONLY the changes from ONE commit from branch A, to branch B?
- How can I reintroduce username an password on git using fedora?
- GIT SKIP EMPTY DIRECTORIES
- Git smudge run once per checkout or per commit?
- I can't find ~/.profile or ~/.bashrc in C:/Users/<user>/.ssh folder
- Set environment variable during push for GitHub Actions
- Android WebRTC compile
Related Questions in CLONE
- Leetcode 1255-recursion and backtracking
- Forking vs Cloning in GitHub
- Trying to run a "uber clone" from github in react native ( vs code )
- I can´t clone my github repository with a ssh key
- Laravel 9 $model->replicate() is not immutable
- Cloning resources group into another
- A way to declare and clone a cloneable (#[derive(Clone)]) struct with a type parameter and a field that is an Arc of an uncloneable type in Rust?
- GIT repo with submodule that can point to two different repositories
- Site Not Found Error After Deployed in Firebase
- PHP Cloning an object when a reference exists breaks the clone
- Git how to pull the update from original repository and keep my own changes
- git svn clone does not grab a branch not in stdlayout
- PDO clone a record then open cloned record to edit
- Problem in Hover Animation in a ReactJS Component
- How to clone an element on click in React.js
Related Questions in GIT-SUBMODULES
- Git hook for git worktree doesn't run "git submodule update --init --recursive" properly
- How to switch branches when a feature branch introduces submodule changes?
- How do I fix error in visual studio code of submodules not opening/cloning correctly?
- Airflow - where to place Dataset definition
- Github action mirroring with automatic submodules resolve
- GIT repo with submodule that can point to two different repositories
- Configuring Submodules for GitHub and Gerrit public repo Integration
- Is it possible to use different libraries as git submodules in a turborepo?
- Is it possible to maintain a git submodule under multiple paths?
- Git submodule: link submodule to local development checkout
- Git nested repo in Visual Studio Code
- Submodules: git status vs git checkout - untracked files
- Sharing a submodule between projects without duplicating the submodule files
- Git sub-repository with URL relative to its parent repository
- In SourceTree, Clone seems to bring submodule files from GitHub repos then seems to delete them
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
After switching branches with
git checkoutorgit switchin the superproject (parent repository) an old.gitmodulesis checked out. If the file has different URLs for the submodules the URLs should be updated in.git/configbecause Git doesn't use URLs from.gitmodulesdirectly, it only uses.git/config. The command to update the URLs isgit submdule sync(add--recursiveif you have a tree of submodules). After thatgit submodule update --initshould update submodules to the respective commits stored in the superproject.You can automate the process with
post-checkouthook. Put thisin
.git/hooks/post-checkout, make the file executable by runningchmod a+x .git/hooks/post-checkout