git diff under the terminal only displays the file name

Usually we can use git diff to view the specific content modification, which will be displayed in the form of patch by default, but sometimes, we just want to have a list of modified files and don’t care about the specific modification content.

This can be achieved with the help of some instructions from git diff.

–name-only

Use –name-only to easily view modified content information

 1 2 3 4 5 6 
git diff --name-only source/_posts/2022-05-08-flutter-run-stuck-with-log-waiting-for-observatory-port-to-be-available.markdown source/_posts/2022-05-15-how-to-find-duplicated-file-via-one-script.markdown source/_posts/2022-05-23-disable-debugprint-and-print-in-flutter-dart-release-mode.markdown source/_posts/2022-05-30-generate-qrcode-in-terminal-on-mac-or-linux.markdown source/_posts/2022-05-31-2022-618-lizhi-dot-io-apps-with-discounts-android-windows-mac-ios.markdown

If it is a branch comparison, you can do this

 1 
git diff a143e219b58ac55df84a1b36da98751e7eeaca80..master --name-only

–stat

If you want to get some brief information, such as how many files were modified, how many lines were added or deleted, you can also use --stat to achieve

 1 2 3 4 5 6 7 
git diff --stat source/_posts/2022-05-08-flutter-run-stuck-with-log-waiting-for-observatory-port-to-be-available.markdown | 49 ++++++++++++++++++++++++ source/_posts/2022-05-15-how-to-find-duplicated-file-via-one-script.markdown | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ source/_posts/2022-05-23-disable-debugprint-and-print-in-flutter-dart-release-mode.markdown | 67 ++++++++++++++++++++++++++++++++ source/_posts/2022-05-30-generate-qrcode-in-terminal-on-mac-or-linux.markdown | 40 +++++++++++++++++++ source/_posts/2022-05-31-2022-618-lizhi-dot-io-apps-with-discounts-android-windows-mac-ios.markdown | 80 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 407 insertions(+)

—numstat

Sometimes, in addition to making it easy for humans to read, it is also necessary to output some formats that are easy for machines to read, so as to facilitate subsequent programming processing and data analysis.

Use –numstat to get a regular format below for easy analysis

 1 2 3 4 5 6 
git diff --numstat 49 0 source/_posts/2022-05-08-flutter-run-stuck-with-log-waiting-for-observatory-port-to-be-available.markdown 171 0 source/_posts/2022-05-15-how-to-find-duplicated-file-via-one-script.markdown 67 0 source/_posts/2022-05-23-disable-debugprint-and-print-in-flutter-dart-release-mode.markdown 40 0 source/_posts/2022-05-30-generate-qrcode-in-terminal-on-mac-or-linux.markdown 80 0 source/_posts/2022-05-31-2022-618-lizhi-dot-io-apps-with-discounts-android-windows-mac-ios.markdown 

droidyue_gzh_green_png.png

This article is reprinted from https://droidyue.com/blog/2022/06/06/git-diff-show-filename-only/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment