Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git submodule functionality with sibling?

I have a project consisting of a library and various applications:

foo/
foolib/
bar/
baz/
qux/foo/

All of the applications link against foolib, a static library.

I would like git commit on foo to record the SHA1 ID of where foolib was at, and also git status on foo to report if there are uncommitted changes in foolib.

However I do not want to move foolib to having a copy of it as a subdirectory of every application. As well as being bloaty, this would lose the ability to try out some changes to foolib in multiple applications without committing the changes.

I have tried making a .gitmodules file that points to ../foolib but it seems to be completely ignored by git status. I also tried making foolib a softlink inside foo, but git seemed to treat the softlink as a file instead of following the link.

Is what I want possible, or do you have any alternative workflow solutions?

On my public repository, the structure is the same, and each application (and foolib) has been cloned individually from the public.

like image 668
user1804620 Avatar asked Nov 12 '22 18:11

user1804620


1 Answers

The idea would be to create another repo fooProject, which would declare as submodules:

  • foo
  • foolib

(If you call your parent project appProjects instead of fooProject, you could declare as submodules all the sub-directories: foo, foolib, bar, baz, ...)

If any of the sub-directories (foo or foolib) changes and makes a new commit, you go back to the parent repo and commit as well, in order to record the SHA1 of the different submodules.

like image 180
VonC Avatar answered Dec 09 '22 15:12

VonC