Search code examples
gitgit-log

git: get the list of files that have been modified along one specific file


I'd like to check which files have been modified at the same time as one specific file. Specifically, I want to get the history of this specific file, and for each commit of this history I want to know which files were affected.

When I do git log --name-only, I get the full history of commits, as well as a list of files that have been modified, for each commit.

Now if I do git log <file>, I get the history of the commits that involved this specific file.

git log --name-only <file>, however, do not include the full list of files modified by each commits. Instead it only shows me <file>, which is quite useless to be honest. Is there any way to make this command include all files?


Solution

  • You can pipeline the two commands.

    $ git log --format="%h" <file-name> | xargs git show --name-only
    

    Here:

    git log --format="%h" : select the commit-sha where the given file is changed

    xargs git show --name-only: takes the selected commits as args and show the full changed file names.