简体   繁体   中英

Git: fast diff viewing before commit

Before I commit I run git status and get output like this:

#   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. Is there a faster way?

Just running git diff should do exactly what you want.

If you want a more graphical view use 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.

SourceTree is my GoTo program for Git.

Git gui is my weapon of choice for this. 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 . from the same directory where you run 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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