kostja
kostja

Reputation: 61578

How to compare a file with a commit from X versions ago

To compare a file with a certain commit that is not the current HEAD, I call git log, note the commit hash and then call git diff <hash> filename.

Is there a way to use the diff command like this: git diff -<x_commits_back> filename and compare the file with a version from x versions ago?

Thank you

Upvotes: 1

Views: 73

Answers (1)

CB Bailey
CB Bailey

Reputation: 793027

Yes, you can use:

git diff HEAD~X -- filename

Replace X as appropriate. Note that it follows the first parent of merge commits.

Upvotes: 5

Related Questions