I have my .dotfiles (.zshrc, .bashrc, etc.) in Git.
I would like to have some extra repos (from me as well) in a plugins
subdirectory -- I do have a custom repo for my Emacs config, another for my LaTeX config, etc.
Does it make sense to create those as submodules? I mean: can I use that as a working copy as well, and directly edit my LaTeX config from the submodule?
Or am I mixing some stuff here? (I would like to avoid having 2 dirs on my machine with the same contents, or almost, for every submodule repo -- and I would like my submodule to be always at the latest version, or almost.)
UPDATE
I do have my main repo (which is an editable working copy at the same time) in /usr/me/.dotfiles
.
If I put submodules in /usr/me/.dotfiles/plugins
(for example), I have the advantage of having all the other puzzle pieces fetched at one, when cloning, but I understand that I can't edit those files directly in there, right? Then, that's a problem... because I do have "task files", for example, which are edited when I reschedule things.
And to properly edit those, I would have to go to /usr/me/dev/repo-task-files
... Not practical at all...
Now, I can just put the plain repos in /usr/me/.dotfiles/plugins
, though not as submodules. It means that, on other machines, I must manually (or via a script) clone the different repos in the same place, but it's not a one-line operation (when cloning dotfiles).
But, then, I can edit the files directly where they are.
My improved question: is the above description right? Is there a 3rd way?
Update
Does it make sense to create those as submodules? I mean: can I use that as a working copy as well, and directly edit my LaTeX config from the submodule?
Yes, submodules are meant to be used as independent repositories. Committing changes inside a submodule is exactly the same as making them in another local copy of the repo. The only difference is you'll have uncommitted changes in the super repo.
If I put submodules in /usr/me/.dotfiles/plugins (for example), I have the advantage of having all the other puzzle pieces fetched at one, when cloning, but I understand that I can't edit those files directly in there, right?
You can edit submodules just like you would any other git repository.
Now, I can just put the plain repos in /usr/me/.dotfiles/plugins, though not as submodules. It means that, on other machines, I must manually (or via a script) clone the different repos in the same place, but it's not a one-line operation (when cloning dotfiles).
The problem with this approach is that any change in the "subrepo" would appear in both repositories. The subproject's folder would be treated just like another tracked directory in the superproject.
When a repo sees its submodule change, it will report a single modified file:
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: plugins/LaTeX (new commits, modified content)
Original answer
The thing about submodules is that you're binding a specific version of the repository to the super project. What if you continued to develop the submodule, and made a change that would break the parent?
By using submodules you make sure to always have a working version.
You shouldn't care about having multiple copies of repositories locally anyway.
If you're concerned about wasting bandwidth when fetching, you could add a remote to a repo pointing to the other local copy.