Skip to content

Instantly share code, notes, and snippets.

@pdsouza
Last active May 29, 2019 12:17
Show Gist options
  • Save pdsouza/4e4a8382177931d8f6f762d47e613cca to your computer and use it in GitHub Desktop.
Save pdsouza/4e4a8382177931d8f6f762d47e613cca to your computer and use it in GitHub Desktop.
notes on git

Quick reference

Which commits are on branch B, but not on branch A?

$ git log --oneline A..B

Which commits are not reachable from both A and B? (Symmetric difference)

$ git log --oneline A...B

Of the commits on branch B, but not on branch A, are any of them equivalent to a commit on branch A? (equivalent commits will have - prefix, new commits will have + prefix):

$ git cherry -v A B

Git bisecting a merge

Take note of ours branch HEAD before the merge: 1d53e49c057b1c990dc9b91406753c3aa2a8ab7a

$ git bisect start
$ git bisect bad
$ git bisect good 1d53e49c057b1c990dc9b91406753c3aa2a8ab7a

This will pick a commit half-way through the merge, but remember this is just checking out that specific commit, so it will go to a point of history from upstream, and will not contain the changes in ours.

To get ours change back, merge the current bisect-chosen commit to ours branch HEAD:

$ git merge --no-commit 1d53e49c057b1c990dc9b91406753c3aa2a8ab7a

Now you will have ours changes back and you can compile and test. In other words, this is the state of ours if you had merged upstream at the current chosen bisected commit.

Before you tell git bisect whether this one is good or bad, reset back:

$ git reset --hard

Then mark it good or bad based on your testing:

$ git bisect bad

And so on!

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