Pan Ruochen
Pan Ruochen

Reputation: 2070

How to compare specific files in different commits in GIT?

From time to time I need to see the changes of specific files in different commits. Is there any simple way to do this without having to reset & checkout the files and rename to another temporary files?

Upvotes: 2

Views: 121

Answers (1)

Norman Ramsey
Norman Ramsey

Reputation: 202475

Try, for example

git diff 278d8..1cf1d www/index.html

Each of the two hex codes is a unique prefix of the SHA1 hash that identifies a commit.

It's also sometimes helpful to browse differences with gitk, but that shows differences between adjacent commits only.

Upvotes: 4

Related Questions