Environment
Setup
I use a git bare repository to version my config files. I can use same commands as if I were using a normal git repository just have to include some flags:
git --git-dir=/home/kunzaatko/.cfg/ --work-tree=/home/kunzaatko/ __command__
instead of
git __command__
Usage
I make use of vim-fugitive with normal git repositories mainly for making a big change and adding it in many different commits by staging partially (only a discrete set of hunks/changes) and committing them separately . I use :Gdiff for this for the nice and productive interface I can make use of.
Desire
I want to do this with my config git bare repository.
What I tried:
Renaming the repository to
.cfg.git. This didn't make any change. issue that suggests this should workI tried to change the
b:git_dirinternal variable of git-fugitive:
:let b:git_dir=/home/kunzaatko/.cfg/
- Changing the working directory to the git directory for fugitive to recognize that it is a git repo:
 
:chdir /home/kunzaatko/.cfg/
What would be worthy of trying if I knew how:
- I think that there may be a way to use the 
git submodulecommand to put the bare repo into scope. The problem with that is where to put the root of the git repository... issue that I base this possibility of of 
Question
Is there a way to use a git bare repository with git-fugitive?
(or any other suggestion that would solve my use-case)
                        
I agree with @okket, but there is a problem when I use that method.
When in Gstatus window, I cannot get the status of changed files. And I find the reason is that fugitive gets the
core.worktreeattribute from theGIT_DIRrepository.So for me, the viable way to do this is as follows:
GIT_DIRenv variable when using vim/nvim command (GIT_WORK_TREEmay be omitted):For users of fish shell (like me), should use
envcommand:core.worktreefor your git repository:You can make sure you get it right with the following command:
The output should be your HOME path.
git clone --bare ..., you need to unsetcore.bareto avoid git status errorwarning: core.bare and core.worktree do not make sense:And there is one more thing to notice for this method. You cannot use fugitive outside of
$HOMEdirectory where you will getfugitive: working directory does not belong to a Git repositoryerror.