Be Kind To New Users
Be Kind To New Users

Reputation: 10063

Get names of all changed files in log of one file

How do I get the names of all changed files from one commit despite specifying a single file on the command line?

For instance, if I do a git log --name-only on the entire repo I will get a log like this:

commit abc... HEAD
Author: Joseph Blow
Date:   Tue Feb 30 ...

    Very important Change

afile.c
anotherfile.c

But if I do this: git log --name-only afile.c, then I get this:

commit abc... HEAD
Author: Joseph Blow
Date:   Tue Feb 30 ...

    Very important Change

afile.c

Despite specifying a file, I want to see all files that were changed with that commit.

[edit] The sample is just one of the many commit messages in the output.

Upvotes: 1

Views: 44

Answers (3)

Fabricio
Fabricio

Reputation: 3297

You can merge git log with git show to do that in one line ;)

git show --name-only $(git log --format=%H -- your_filename.c)

Git show accept a list of hash as an argument and git log with --format=%H generate a list of hash that involves afile.c commits, then this list is used as a input for git show.

I hope that helps :D

Upvotes: 0

Paul Hicks
Paul Hicks

Reputation: 13999

In git, this can be done in two commands. After you've done the git log to find the sha1, you can then use git show --name-only <sha1> to get the names of the other files in that commit.

Upvotes: 0

Vampire
Vampire

Reputation: 38639

git log --name-only --full-diff afile.c

Despite the name this will not show a full diff, but means "do consider all files, not only the specified ones".

Upvotes: 2

Related Questions