What does --oneline in git diff do?

Viewed 3052

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?

2 Answers

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.

git diff --oneline does nothing special. It just so happens that git log and git diff share a large part of the command line parser (because all the diff options also apply to log). For this reason, git diff does not complain about the presence of --oneline and only ignores it.

Related