If git-dir
is not in work-tree, we can use the command line
git --work-tree=/a/b --git-dir=/c/d/ status
to run git. How can we use magit in this situation? Thanks.
Create a file /path/to/worktree/.git
with contents gitdir: /path/to/gitdir
and in /path/to/gitdir/config
set core.worktree
to /path/to/worktree
. You can also use relative paths. Git commands which create separate worktrees do that (e.g. git submodule
).
git worktree
does something a bit different because it has to support multiple worktrees. But depending on your use-case, you might be able to just use that command instead doing it manually.