Note that the proposed solution (2012, pre Git 2.5 which will be released in July 2015) would not work directly with git config
command.
It would keep dying with a:
fatal: core.bare and core.worktree do not make sense.
That is what Git 2.5 (July 2015) will address:
See commit fada767 (29 May 2015) by Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
-- in commit 103b6f9, 16 Jun 2015)
setup_git_directory
: delay core.bare
/core.worktree
errors
If both core.bare
and core.worktree
are set, we complain
about the bogus config and die.
Dying is good, because it
avoids commands running and doing damage in a potentially
incorrect setup.
But dying there is bad, because it means
that commands which do not even care about the work tree
cannot run.
This can make repairing the situation harder:
[setup]
$ git config core.bare true
$ git config core.worktree /some/path
[OK, expected.]
$ git status
fatal: core.bare and core.worktree do not make sense
[Hrm...]
$ git config --unset core.worktree
fatal: core.bare and core.worktree do not make sense
[Nope...]
$ git config --edit
fatal: core.bare and core.worktree do not make sense
[Gaaah.]
$ git help config
fatal: core.bare and core.worktree do not make sense
Instead, let's issue a warning about the bogus config when
we notice it (i.e., for all commands), but only die when the
command tries to use the work tree (by calling setup_work_tree).
So we now get:
$ git status
warning: core.bare and core.worktree do not make sense
fatal: unable to set up work tree using invalid config
$ git config --unset core.worktree
warning: core.bare and core.worktree do not make sense