Skip to content

Instantly share code, notes, and snippets.

@lava
Created January 17, 2020 09:49
Show Gist options
  • Save lava/dc4740c4cfb45eb5703e6b579f2f60d8 to your computer and use it in GitHub Desktop.
Save lava/dc4740c4cfb45eb5703e6b579f2f60d8 to your computer and use it in GitHub Desktop.
Git Merge Commit Cheatsheet

Git Merge Commit Cheatsheet

Show contents of merge commits in git log -p output:

git log -c

Show changes to current branch in the last 24 hours:

git rev-list --no-merges HEAD \
    --not $(git rev-list -n1 --before="24 hours" --first-parent HEAD)

Default commit selection algorithm for git log:

Commits are included if they are not TREESAME to any parent.
If the commit was a merge, and it was TREESAME to one
parent, follow only that parent. (Even if there are several
TREESAME parents, follow only one of them.) Otherwise, follow
all parents.

Ordering algorithms for git log:

  • Reverse chronological order of commit timestamps, with no parent/child constraints. [default]

  • --[author-]date-order Show no parents before all of its children are shown, but otherwise show commits in the commit [author] timestamp order.

  • --topo-order Show no parents before all of its children are shown, and avoid showing commits on multiple lines of history intermixed.

Behaviour of '~N' operator:

Follows the *first* parent N times. (I.e. it will skip whole branches by default.)
One can use `git log --first-parent` to see the target list of '~'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment