如何在逃犯中编辑特定版本的文件

时间:2022-04-11 17:18:35

Some content has been moved from a .c file to a .h 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.

某些内容已从.c文件移动到我的存储库中的.h文件,我想比较它们以确保新标头正确。这是Gerrit的评论,我假设使用Gerrit工具链没有简单的方法。

I am trying to edit the .h file in one window and the old version of the .c 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.

我试图在一个窗口和旧版本的.c文件中编辑.h文件。当我发出Gedit FETCH_HEAD时:path / from / root / to / file.c总是会出现以下错误:E492:不是编辑器命令:Gedit FETCH_HEAD:path / from / root / to / file.c。我也尝试使用哈希命令。

What am I missing?

我错过了什么?

2 个解决方案

#1


0  

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

只有在当前缓冲区由git控制或vim首次启动时才在git目录中,才能使用逃逸命令。

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

在发出:Gedit命令之前,只需打开git存储库中的任何文件。

:e path/from/root/to/file.c
:Gedit FETCH_HEAD:%

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

注意:使用%表示当前文件。见:h c_%

#2


0  

Use the "git show" command to get the files/versions you want to compare:

使用“git show”命令获取要比较的文件/版本:

> git show version1:file1 > any_name_1
> git show version2:file2 > any_name_2

Then open the files in gedit editor or (better) use some diff tool like, for example, KDiff3 to see the differences between the two files/versions.

然后在gedit编辑器中打开文件或(更好)使用一些差异工具,例如,KDiff3来查看两个文件/版本之间的差异。

> kdiff3 any_name_1 any_name_2

#1


0  

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

只有在当前缓冲区由git控制或vim首次启动时才在git目录中,才能使用逃逸命令。

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

在发出:Gedit命令之前,只需打开git存储库中的任何文件。

:e path/from/root/to/file.c
:Gedit FETCH_HEAD:%

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

注意:使用%表示当前文件。见:h c_%

#2


0  

Use the "git show" command to get the files/versions you want to compare:

使用“git show”命令获取要比较的文件/版本:

> git show version1:file1 > any_name_1
> git show version2:file2 > any_name_2

Then open the files in gedit editor or (better) use some diff tool like, for example, KDiff3 to see the differences between the two files/versions.

然后在gedit编辑器中打开文件或(更好)使用一些差异工具,例如,KDiff3来查看两个文件/版本之间的差异。

> kdiff3 any_name_1 any_name_2