I don't know how vim-fugitive checks if the current file is under a git repository, but for this specific case you can follow the following steps to get the job done:
:file <path/to/file>
:edit
Here, :file <path/to/file>
changes the associated file of the current buffer to the provided file and :edit
reloads the current buffer. A buffer is the in-memory text of a file. So, what you see on the window/split is actually a buffered memory (hence the name buffer
). When you do :write
, you save the current buffered memory to the associated file and when you do :edit
, you reload the current buffered memory with the content of the associated file. So, when you do :file <path/to/file>
you change the associated file of the current buffer and henceforward do any interaction with that file.
Now, when you changed the associated file and reloaded it, the buffer checked that it's in a git repository and launched vim-fugitive instance; or so I conjecture since I already got the confirmation that this solution worked from the OP.
Check out :h file_f
for more information.
:h :0file
and:h :file_f
– klaus Aug 18 '19 at 6:47e
to reload. – eyal karni Aug 18 '19 at 15:25