Reputation: 8174
I have some files in my repository that take a lot of space as compared to the rest which are just text files. So, I decided to keep them in separate git repositories in order to keep the main code repository compact, and link the others as git submodules.
However, I don't need git to update working tree since I already have them on my development machine. I just need the main repo keep references to the submodules.
Once I commit something to the submodule and push, how do I just update the main repo's pointers to the submodule commits?
In my experience, git does not allow me update
without git submodule init
, and that updates the working tree.
Upvotes: 2
Views: 877
Reputation: 588
You can directly set the submodule reference to an arbitrary sha1 hash using
git update-index --cacheinfo 160000,<submodule commit hash>,<submodule path>
The first argument is always 160000, meaning "submodule".
This has the same effect on the index as git add <submodule path>
, but does not require you to initialize the submodule.
Upvotes: 0
Reputation: 997
If I get your idea right, your question can be summed up to
fetch information of submodule commit without fetching files
However, the mechanism of git makes it impossible.
Because there is no isolated commit information, which are based on commit objects, which is in turn based on files.
You have those files on your machine, but what git needs is commit objects, not just files themselves.
So you get the newest commit information of submodule when you fetch the commit objects. There is no such thing as fetching only the commit information.
Therefore, if you want to make a reference of newest commit of submodule (or rather merge changes of submodule into main repo), you have to fetch that submodule in order to get the commit information, then add the newest commit of submodule to the main repo.
Upvotes: 1