Recovering from 'fatal: core.bare and core.worktree do not make sense'
- From
SZEDER Gábor <szeder@ira.uka.de>
- Date
- May 27, 2015, 10:31 UTC
- Message-ID
- <20150527123147.Horde.GqzoX-7JvXiOGBlB5moP4A8@webmail.informatik.kit.edu>
Hi,
the other day I said 'git config core.worktree /somewhere' in a bare repo while thinking I was in a regular one, user error. The 'fatal: core.bare and core.worktree do not make sense' error from the next command made me realize immediately that I was wrong, that's good. However...
OK, let's have a look and recover from the situation:
$ git config --edit
fatal: core.bare and core.worktree do not make senseWell, all was well before I set 'core.worktree', so let's unset it:
$ git config --unset core.worktree
fatal: core.bare and core.worktree do not make senseHmph, not expecting much, but how about unsetting the other variable?
$ git config --unset core.bare
fatal: core.bare and core.worktree do not make senseGood, at least it's pretty consistent, though I still don't get what 'git config' has to do with the worktree that is so important that it has to bail out. Time to look for help:
$ git help config
fatal: core.bare and core.worktree do not make senseWTF :) Alright, I give up:
$ vim config
$ # happyIt was two days later that I had a bit of a lightbulb moment, reproduced the situation and just for fun tried this:
$ git -c core.bare=false config --unset core.bare
I didn't expect, but it worked! Great.
Some thoughts:
1) Perhaps 'git config' should be more careful in the first place
and refuse to set 'core.worktree' when 'core.bare' is already
true and vice versa. 2) The damage was done with 'git config', so I expected that I can
repair it with "plain" 'git config' (i.e. without 'git -c') as
well. 'git config' has nothing to do with the path to the
worktree after all. And 'git config --edit' should work
regardless of the mess that might be in the config file. 3) 'git help <cmd>' should always work, shouldn't it? (Though
that's the easiest to remedy, just cd out of the repo, or fire
up a new terminal window.)Gábor