简体   繁体   中英

why “git show --name-only --pretty=format:” could show only names of affected files

From git documentation, git show --name-only Show only names of changed files. But with command git show --name-only , it outputs other info like commit id and and author and commit messages, etc.

And I also know --pretty=format:<format> could format the output, but why given empty <format> , the output filters out other info when only using git show --name-only ?

Edited:

With exact command git show --name-only --pretty=format: (nothing after colon), the output is exactly the lines of changed files. My question is more about why given no format it outputs such result?

From the "DESCRIPTION" section after executing git show --help : "For commits it shows the log message and textual diff. ..."

The --name-only flag tells it not to include the textual diffs of the changed files.

The documentation could be a bit clearer here.

From the OPTIONS section after executing git show --help

--pretty[=] --format= Pretty-print the contents of the commit logs in a given format, ...

See the "PRETTY FORMATS" section for some additional details for each format. ...

So, --pretty affects the formatting of the commit message, and only the commit message. And from the PRETTY FORMATS section:

format:

  The format:<string> format allows you to specify which information you want to show. It works a little bit like printf 

format...

  Eg, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n" would show something like this: The author of fe6e0ee was Junio C Hamano, 23 hours ago The title was >>t4119: test autocomputing -p<n> for traditional diff input.<< 

The format option allows total control over how and what is displayed, in place of the commit message. In your case, you told it you wanted nothing displayed.

Good luck.

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