Skip to content

Instantly share code, notes, and snippets.

@chrisb13
Last active January 30, 2026 00:03
Show Gist options
  • Select an option

  • Save chrisb13/b0c912a60e436a3f43d52471d8886314 to your computer and use it in GitHub Desktop.

Select an option

Save chrisb13/b0c912a60e436a3f43d52471d8886314 to your computer and use it in GitHub Desktop.
A journey into git diff

This is a lesson by way of a sandbox repository. We have a file at commit A that looks like:

# double-triple-dot-git

This line will be used for commit B: I am adding some text for commit B

This line will be used for commit C: I am adding some text for commit C

This line will be used for commit D: I am adding some text for commit D

We will have 6 additional commits. Across the following branches:

A - B        main
  \
   C - D     test
A - B'        main_minus
  \
   C' - D'     test_minus

A commit with just a letter adds to the related line whereas a commit with a prime (') will remove the text on the related line. See the commits here (these show you the difference to the parent, so do look at the diagram above):

Here is our full repo history:

* d3a0377   D' (origin/test_minus)
|
* 5dd0906   C'
|
| * c41c8ef D  (origin/test)
| |
| * 232caf4 C
|/
| * dd9c11e B' (origin/main_minus)
|/
| * 29adf51 B  (origin/main)
|/
* fd3c4fb   A
|
* bf39729   Initial commit - Christopher Bull

Suggested links:

  1. main..test;
  2. main...test;
  3. main_minus..test_minus;
  4. main_minus...test_minus.

Note that PRs are based on 3 dot diffs. Note that in the 4th example above there's a possible gotcha on an actual merge! (All lines will be deleted).

Feel free to add to the explanations above and fork the repo'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment