Search code examples
gitgit-diffgit-log

What does --oneline in git diff do?


In this answer of mine, I have kept from the question an option I didn't know of, namely --oneline applied to git diff instead of git log. But searching for oneline in man git-diff doesn't give any result. Still git diff --oneline doesn't error.

What is it for?


Solution

  • According to git-diff documentation, the command shows the changes between commits, commit and working tree, etc. The git-diff-tree command is part of git-diff, it compares two tree objects. This makes it possible to use the option. It is a short form of --pretty=oneline --abbrev-commit. I also found a comment in the git-log documentation:

    The command takes options applicable to the git rev-list command to control what is shown and how, and options applicable to the git diff-* commands to control how the changes each commit introduces are shown.

    So I suspect it is a possible option for a subcommand, but it has no effect on the git-diff command.