I do not recommend doing this, but it sounds like you're dead-set... Note that this will cause files from your "submodule" to be committed in two places, and keeping them in sync will be an additional challenge.
My opinion is that this is at least as complicated as submodules, and since it's a weird thing to do other developers who want to contribute will likely be confused.
You could move the .git
directory out of your submodule directory so that
- your main Git repository does not view the "submodule" directory as a submodule, and
- you can still fetch from upstream.
Here is a short example:
Clone something (your "inner repository") into a subdirectory of your main repository:
~ $ cd repo
~/repo/ $ git clone git://some-other-repo.git/
Create a directory to hold the .git
directory from your inner repository somewhere outside of your main repository, and move your inner .git
directory there:
~/repo/ $ cd ..
~ $ mkdir -p fake-submodules/some-other-repo/
~ $ mv ~/repo/some-other-repo/.git fake-submodules/some-other-repo/
Now, from your main repository you can add all of the files and commit as usual:
~ $ cd repo
~/repo/ $ git add some-other-repo
~/repo/ $ git commit -m "Add some other repo"
And you can fetch updates from your upstream repository using Git's --work-tree
option:
~/repo/ $ cd ../fake-submodules/some-other-repo
~/fake-submodules/some-other-repo/ $ git --work-tree ../../repo/some-other-repo status
~/fake-submodules/some-other-repo/ $ git --work-tree ../../repo/some-other-repo fetch
~/fake-submodules/some-other-repo/ $ git --work-tree ../../repo/some-other-repo merge origin/master
Note that you would have to perform all Git operations for your inner repository from its fake-submodules
directory. You will probably want to do something like git config core.worktree ../../repo/some-other-repo
to avoid having to type the --work-tree
option in each time.
Again, please reconsider doing this. Git's submodules may not be perfect, but at least they're widely used and understood. As VonC says, there are other more appropriate options as well, like subtrees.