Reputation: 2220
I copy pasted a git repository from windows to linux, from a shared directory, to a standard one. And now, any git
command returns the error:
fatal: Invalid path '/shared': No such file or directory.
I tracked down the issue to a vestigial parameter from .git/config
which defines:
[core]
worktree = //shared/directory/source/project
Indeed, under linux, this dir does not exist nor is a valid path... I could solve the issue by deleting the incriminated line. But I couldn't find a single git command to reset this in a cleaner manner.
Upvotes: 2
Views: 1974
Reputation: 487755
The core.worktree
setting is documented.
If you want to change it using a Git command, use git config core.worktree new-setting
. If you want to delete it, use git config --unset
or git config --unset-all
.1 Of course, if it's currently set to an unusable path, you get an error:
$ git config core.worktree /no/such/path
$ git config --get core.worktree
fatal: Invalid path '/no': No such file or directory
It might be nice if git config
caught this problem internally and just avoided the attempt to chdir
to the core.worktree
path, but there's an easy workaround:
$ git --work-tree=. config --unset core.worktree
so unless/until someone modifies Git to avoid the early fatal
, use the workaround.
1The only reason to use --unset-all
is if there is more than one core.worktree
setting. Normally there would not be.
Upvotes: 4