More ways to do it
git --work-tree=~/b/content/data add .
will do it for one-time use (the pathname you specify is relative to the given worktree)
Check whether the worktree you specify has any nested repositories in it (find that/path -name .git
), those are also known as submodules and what will be added to your own repository is just the currently-checked-out commit id there.
Note that checkout like add is always to the current worktree, so if you do the above command, then commit, then checkout without the override, you'll get ~/b/content/data
's innards checked out under ~/a
.
If you want to set a persistent worktree for the repository,
git config core.worktree ~/b/content/data
or as a relative path (relative to the .git directory)
git config core.worktree ../../b/content/data # ~/a/.git/.. is ~/a