Search code examples
gitgit-submodules

Can I use git submodule to manage individual files as well as directories?


I have a complex repository where sometimes the logical boundaries between code segments crosses directory boundaries. Sometimes a single file in directory X really needs to go with files in directory Y.

E.g., pretend I have a central repo that looks like this:

a/foo
a/bar
b/baz1
b/baz2

...and I want my local repository to end up with a/* and b/baz1, but not b/baz2.

(Yes, the long term solution is to move the files, but while I am working on that refactoring, I need to version-control the files appropriately.)

Can I use git submodule to work on a set of code that includes some directories and some other random files? How would I do this?


Solution

  • No, the Git "submodule" feature is limited to subdirectories and all the files they contain.