Stephen Rasku Stephen Rasku - 9 months ago 51
Git Question

How to edit specific version of file in fugitive

Some content has been moved from a

file to a
file in my repository and I want to compare them to ensure that the new header is correct. This is for a Gerrit review and I am assuming there's no simple way to do this using the Gerrit toolchain.

I am trying to edit the
file in one window and the old version of the
file. When I issue the
Gedit FETCH_HEAD:path/from/root/to/file.c
always gives the following error:
E492: Not an editor command: Gedit FETCH_HEAD:path/from/root/to/file.c
. I've also tried the command using the hash.

What am I missing?


Fugitive commands are only available when the current buffer is controlled by git or when vim first starts up is in a git directory.

Just open any file in the git repository before issuing your :Gedit command.

:e path/from/root/to/file.c

Note: Using % to represent the current file. See `:h c_%