0

I can show the history that changed files at specify hash using Github or Git Tools(SourceTree, SmartGit).

How can I show the history that changed files at specify hash using Git command?

Github

1 Answers1

2

You can show the commit SHAs which have affected a given file with git-log and show those changes with git-show as @joanis suggests:

git log <path>

git show <hash> <path>

You may also show this output using git-diff. This might be more helpful if you would like to see the changes on a file over multiple commits rather than a single one at the cost of being more verbose:

# changes made by the commit
git diff <hash>~ <hash> <path>

# changes made by the commit and the previous one
git diff <hash>~2 <hash> <path>

See this question for more info about referencing previous commits

joshmeranda
  • 3,001
  • 2
  • 10
  • 24
  • 1
    `git show` is basically an alias for `git log -1 --patch`, the shortest rendition for a single commit would be `git log -1 -m -p -- path`, with `-m` to get the patch even for merges. – jthill Mar 10 '21 at 20:10