'How do I update a git submodule without checking it out
I am using a git submodule in a very usual way. The way how people typically update a submodule is by checking it out, pulling something in the submodule and then commiting outside.
Now, I typically don't develop those modules in the same place. For me it's more comfortable to develop those two modules in different places. How do I just tell my git project that one submodule has changed and is now at commit XYZ?
I think there's a chance that there's a setting somewhere in .git that I could modify.
Solution 1:[1]
A self-explanatory example :
git update-index --cacheinfo 160000,03d7dff560ac8ed64f16e763204b04ce91ca5faf,submodules/submodule
Explanation:
- 160000 : mode; here it indicates a directory (see doc and search for 160000)
- 03d7dff560ac8ed64f16e763204b04ce91ca5faf: the commit id (or commit hash or sha-1) in the submodule repository to which you want to point from your current repository
- submodules/submodule: path the the submodule location in the git repository, no trailing slash (gives error), no .git
Remember, this only updates the index, you are still expected to commit the change!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
