git Git格式补丁查看器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6948573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:46:49  来源:igfitidea点击:

Git format-patch viewer?

git

提问by big_gie

Somebody is sending me patches generated by "git format-patch".

有人正在向我发送由“git format-patch”生成的补丁。

Is there a gui (on linux) that can open these .patch files?

是否有可以打开这些 .patch 文件的 gui(在 linux 上)?

I've tried many diff gui but all they do is compare two existing files/folders. None can display the patch, except kompare which spits a "The diff is malformed. Some lines could not be parsed and will not be displayed in the diff view." everytime.

我尝试了很多 diff gui,但他们所做的只是比较两个现有的文件/文件夹。没有可以显示补丁,除了 kompare 吐出“差异格式错误。某些行无法解析,不会显示在差异视图中。” 每次。

采纳答案by Karl Bielefeldt

They're pretty easy to read, but if you want to see the entire context of the file, the best way is to apply them with git-am:

它们很容易阅读,但是如果您想查看文件的整个上下文,最好的方法是使用它们git-am

git am foo.patch
git difftool ORIG_HEAD

If you like it, it's already committed. If not:

如果你喜欢它,它已经承诺了。如果不:

git reset --hard ORIG_HEAD

回答by megatops

I've made a tool to view diff side-by-side: https://app.box.com/s/l8rmp281aptq711fqwve

我制作了一个并排查看差异的工具:https: //app.box.com/s/l8rmp281aptq711fqwve

Screenshot: enter image description here

截屏: 在此处输入图片说明

Now it was updated to v0.4 to support file list.

现在已更新到 v0.4 以支持文件列表。

Source code: https://github.com/megatops/PatchViewer

源代码:https: //github.com/megatops/PatchViewer

回答by Justin Weiss

The .diffand .patchfiles that git generates are just plain-text diff files.

git 生成的.diff.patch文件只是纯文本差异文件。

Most text editors on linux should be able to open and syntax-highlight the diff files. Emacs and vim should be able to view them without any problem, as should gedit, kate, or pretty much any other syntax-highlighting text editor.

Linux 上的大多数文本编辑器都应该能够打开差异文件并对其进行语法高亮显示。Emacs 和 vim 应该能够毫无问题地查看它们,gedit、kate 或几乎任何其他语法高亮文本编辑器也应该如此。

If you don't need syntax highlighting, less, cat, or anything else that displays plain text should also show you the changes.

如果您不需要语法突出显示,lesscat或任何其他显示纯文本的内容也应该显示更改。

回答by davvid

Git Colaincludes an "Apply Patches" dialog that can be launched from the Actions menu, or via the git cola amsub-command. You can open patches in this dialog and display the contents with diff syntax highlighting.

Git Cola包括一个“应用补丁”对话框,可以从操作菜单或通过git cola am子命令启动。您可以在此对话框中打开补丁并使用差异语法高亮显示内容。

This feature is available in masterby cloning the repo and will be in the upcoming v3.3release.

此功能可master通过克隆 repo 获得,并将在即将v3.3发布的版本中提供。

回答by LaC

They are supposed to be human-readable text. Open them in a text editor.

它们应该是人类可读的文本。在文本编辑器中打开它们。

Edit: or apply the patch on a branch, then you can use whatever tool you normally use to compare branches.

编辑:或在分支上应用补丁,然后您可以使用您通常使用的任何工具来比较分支。

Edit 2: oh you already thought of that, never mind.

编辑 2:哦,你已经想到了,没关系。