DEV Community

Hammad Malik
Hammad Malik

Posted on

Something I Learned Today: Using `git diff` and `git log -u` to see changes in a file between commit

Problem

I have to make changes to a template file, but on my current branch I was working with the database. So I want to make a new branch just for the Template updates, but need to double check that I didnโ€™t make a change to that file in the commit history of the separate branch

Resources

Findings

  • <commit_0>..<commit_1> is shorthand for checking the differences between two commits, not to be confused with...
  • <commit_0>...<commit_1> - with three dots - which also covers all the commits between the two commits inclusively. Two dots simply compares one with another.
  • And you can also exclude one of the commit references, and it will fall back as if HEAD were used as the value instead. Oh, and you can just use HEAD

Further Research

  • It appears you can do stuff like HEAD^^ and HEAD~2, but I donโ€™t know what that means yet ๐Ÿ˜ฌ

Top comments (1)

Collapse
 
dsryberg profile image
D. Severin Ryberg

Hey Hammad,

I learned a thing about git today. Thanks!

Also, congrats on the first post

-David