Skip to content

Commit 2f1bb2d

Browse files
committed
Document how submodule alternates can be set up (#354)
1 parent 983eff4 commit 2f1bb2d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

_docs/060_alternates.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,32 @@ Configuring Git this way includes `.gitconfig.local` in the standard
199199
`.gitconfig`. yadm will automatically link the correct version based on the
200200
operating system. The bulk of your configurations can go in a single file, and
201201
you just put the exceptions in OS-specific files.
202+
203+
## Submodule alternates
204+
205+
Git submodules can be conditionally enabled using a [conditional git-config
206+
include][git-config-includes] and the `submodule.active`
207+
[configuration][gitsubodules-active].
208+
209+
1. Add the submodule as usual: `yadm submodule add <url> <name>`
210+
2. Add the following to `$HOME/.gitconfig` to include a config only for the
211+
specific repository:
212+
213+
```ini
214+
[includeIf "gitdir:~/.local/share/yadm/repo.git"]
215+
path = .gitconfig.submodules
216+
```
217+
3. Set up `.gitconfig.submodules` to be an alternate or template file that
218+
e.g. contains this on the system where you don't want the submodule checked
219+
out:
220+
221+
```ini
222+
[submodule]
223+
active = *
224+
active = :!<name>
225+
```
226+
4. Run `yadm submodule update` from the [bootstrap](bootstrap) program to check
227+
out all active submodules.
228+
229+
[git-config-includes]: https://git-scm.com/docs/git-config#_conditional_includes
230+
[gitsubodules-active]: https://git-scm.com/docs/gitsubmodules#_active_submodules

0 commit comments

Comments
 (0)