LinuxCommandLibrary

git-whatchanged

Show changes for each commit

TLDR

Display logs and changes for recent commits

$ git whatchanged
copy

Display logs and changes for recent commits within the specified time frame
$ git whatchanged --since "[2 hours ago]"
copy

Display logs and changes for recent commits for specific files or directories
$ git whatchanged [path/to/file_or_directory]
copy

SYNOPSIS

git whatchanged [options] [rev-list options] [-- [path...]]

PARAMETERS

-p, --patch
    Show the patch (diff) for each commit.

-s, --no-patch
    Suppress showing patch output (default if not using -p).

-U<n>, --unified=<n>
    Generate diffs with n lines of context instead of the default 3.

--abbrev-commit
    Show only the abbreviated commit hash.

--pretty=<format>
    Format the output using a predefined style or custom format. Note: git log offers superior formatting.

-n <n>, --max-count=<n>
    Limit the number of commits to output.

--since=<date>, --after=<date>
    Show commits more recent than a specific date.

--until=<date>, --before=<date>
    Show commits older than a specific date.

--author=<pattern>
    Limit commits to those where the author matches the pattern.

--committer=<pattern>
    Limit commits to those where the committer matches the pattern.

--grep=<pattern>
    Limit commits to those with commit messages matching the pattern.

-S<string>, --pickaxe-regex
    Show commits that add or delete an instance of the given string (search by content changes).

-G<regex>
    Show commits where the diff introduces or removes lines matching the regex.

<path>...
    Limit commits to those that touch the specified paths. The -- separator can be used for clarity.

DESCRIPTION

The git-whatchanged command displays commit history and, optionally, patch differences for changes made to a Git repository. It is a historical command that has largely been superseded by git log -p, which offers more flexibility and control over output formatting. git-whatchanged traverses the commit graph starting from the HEAD (or specified revisions) and shows each commit's metadata (author, date, commit message hash) along with a summary of changed files (diffstat) and the actual patch content if requested. It's useful for quickly reviewing what changes were introduced by a series of commits, especially when migrating from older VCS systems or working with scripts that historically used this command.

CAVEATS

The git-whatchanged command is considered a legacy command. While it still functions, git log -p is the modern and recommended alternative for viewing commit history with patches. git log offers a richer set of options for filtering, formatting, and traversing the commit graph, making it significantly more powerful and flexible. New scripts and workflows should strongly prefer git log.

<I>DEFAULT OUTPUT</I>

By default, git-whatchanged prints the commit ID, author, and date, followed by a diffstat (summary of changes) for each commit, without the actual patch content. To see the full patch, the -p option is required.

<I>COMPARISON WITH GIT LOG</I>

While git-whatchanged focuses on showing changes, git log is a more general-purpose history browser. Any query achievable with git-whatchanged can be done with git log -p, often with greater flexibility and more pleasant output. For instance, git whatchanged -p is largely equivalent to git log -p --stat --summary.

HISTORY

git-whatchanged was one of the earliest commands in Git's history, designed to provide a "changelog" like view, similar to cvs annotate or svn log. Its primary purpose was to show which commits changed what files. As Git matured, the more generalized and powerful git log command evolved, incorporating and expanding upon the functionalities of git-whatchanged, particularly with its extensive formatting and filtering capabilities. Consequently, git-whatchanged has been largely deprecated in favor of git log -p since Git version 1.7.0, though it remains available for backward compatibility.

SEE ALSO

git log(1), git show(1), git diff(1)

Copied to clipboard