serhii.net

In the middle of the desert you can say anything you want

28 Feb 2023

git diff to find differences in file between revisions

git diff [--options] <commit> <commit> [--] [<path>...]

For example, for ‘between now and 2 commits back’:

$ git diff HEAD^^ HEAD main.c
$ git diff HEAD~2 HEAD -- main.c

Paths need to be relative to the root of the repo.

Another option (can do different files) is:

git diff <revision_1>:<file_1> <revision_2>:<file_2>

Source: git - How do I diff the same file between two different commits on the same branch? - Stack Overflow

(Bonus: the -- makes it work for files with weird names like -p, good for scripts but rarely needed in practice).

Previously: 230221-1406 Gitlab has a git graph and comparisons

Nel mezzo del deserto posso dire tutto quello che voglio.