Find recently added files with git

git whatchanged --diff-filter=A displays commits that added files, and the files they added, newest first.


git diff --diff-filter=A --name-only HEAD

You could try this, --diff-filter=A is for files that are added and not committed yet. Refer diff manual page for more details. You could also try out ls-files as per your requirement. Hope this helps!


See @Dave Vandervies's answer as well.

1. See a log of only Added files:

git whatchanged --diff-filter=A

# [preferred] OR, very similar, but slightly cleaner/less verbose file information
git log --name-status --diff-filter=A

2. See a log of both Added AND Modified files:

If you want to see also modified files, use instead AM:

git whatchanged --diff-filter=AM

# [preferred] OR, very similar, but slightly cleaner/less verbose file information
git log --name-status --diff-filter=AM

3. To see a log of ANY and ALL types of changes, use the default:

git whatchanged

# [preferred] OR, very similar, but slightly cleaner/less verbose file information
git log --name-status

Other options include the following (from man git diff, search for --diff-filter=):

--diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
    Select only files that are Added (A), Copied (C),
    Deleted (D), Modified (M), Renamed (R), have their
    type (i.e. regular file, symlink, submodule, ...)
    changed (T), are Unmerged (U), are Unknown (X), or
    have had their pairing Broken (B). Any combination
    of the filter characters (including none) can be
    used. When * (All-or-none) is added to the
    combination, all paths are selected if there is any
    file that matches other criteria in the comparison;
    if there is no file that matches other criteria,
    nothing is selected.
        
    Also, these upper-case letters can be downcased to
    exclude. E.g.  --diff-filter=ad excludes added and
    deleted paths.
        
    Note that not all diffs can feature all types. For
    instance, diffs from the index to the working tree
    can never have Added entries (because the set of
    paths included in the diff is limited by what is in
    the index). Similarly, copied and renamed entries
    cannot appear if detection for those types is
    disabled.

4. Optionally specify a branch name or commit hash:

Note that for all the commands above, you can optionally also specify a branch name or commit hash. Ex:

git whatchanged commit_hash

# [preferred] OR, very similar, but slightly cleaner/less verbose file information
git log --name-status commit_hash

5. To see just a single list (NOT a multi-entry log) of changed files, with their Modified/Added/etc. status:

git diff --name-status commit_hash

# OR, name only (no status character)
git diff --name-only commit_hash

NOTES: git whatchanged vs git log:

git officially recommends git log over git whatchanged. They say git whatchanged exists "primarily for historical reasons." See man git whatchanged:

DESCRIPTION
       Shows commit logs and diff output each commit introduces.

       New users are encouraged to use git-log(1) instead. The whatchanged
       command is essentially the same as git-log(1) but defaults to show
       the raw format diff output and to skip merges.

       The command is kept primarily for historical reasons; fingers of
       many people who learned Git long before git log was invented by
       reading Linux kernel mailing list are trained to type it.