简体   繁体   English

Git:提交前快速查看差异

[英]Git: fast diff viewing before commit

Before I commit I run git status and get output like this: 在我提交之前,我运行git status并获得如下输出:

#   modified:   TemplateDemo/src/com/example/templatedemo/Item.java
#   modified:   TemplateLib/res/layout/layout_list.xml
#   modified:   TemplateLib/res/layout/list_header.xml
#   modified:   TemplateLib/res/values/strings.xml
#   modified:   TemplateLib/src/com/saturn/templatelibrary/ISwappableAdapter.java
#   modified:   TemplateLib/src/com/saturn/templatelibrary/ItemAnimator.java
#   modified:   TemplateLib/src/com/saturn/templatelibrary/SwappableAdapter.java
#   modified:   TemplateLib/src/com/saturn/templatelibrary/TemplateListActivity.java
#   modified:   TemplateLib/src/com/saturn/templatelibrary/TemplateListFragment.java

Now I want to view diff for each file. 现在,我想查看每个文件的差异。 Now I do it like this: I manually select each filename from the command this output and run meld <filename> for each file in the list. 现在,我这样做:从输出命令中手动选择每个文件名,并对列表中的每个文件运行meld <filename> Is there a faster way? 有没有更快的方法?

Just running git diff should do exactly what you want. 仅运行git diff应该可以完全满足您的要求。

If you want a more graphical view use git difftool . 如果您想要更多的图形化视图,请使用git difftool

There are many third party programs that make Git much simpler to use, and also show you diffs of each file before you stage them, and even allow you to stage chucks at a time. 有许多第三方程序使Git更加易于使用,并且还可以在暂存文件之前向您显示每个文件的差异,甚至允许您一次暂存卡盘。

SourceTree is my GoTo program for Git. SourceTree是我的Git GoTo程序。

Git gui is my weapon of choice for this. Git gui是我为此选择的武器。 You can easily scan through each file and see what's removed, and what is added. 您可以轻松浏览每个文件,并查看删除的内容和添加的内容。

I manually select each filename... Is there a faster way?

Yes. 是。 If you prefer meld for viewing diffs you can run meld . 如果您更喜欢使用meld查看差异,则可以运行meld . from the same directory where you run git status . 从运行git status的同一目录。 Then you can select any filename in meld GUI to view diff or view diffs for all files at once with every diff in separate tab. 然后,您可以在meld GUI中选择任何文件名来查看差异或一次查看所有文件的差异,而每个差异都在单独的选项卡中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM