From b789d8b4636cb30a4f6fd7a84eb5c46c97ae9f46 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 12 Aug 2016 16:31:46 -0500 Subject: [PATCH] Add List Different Commits Between Two Branches as a git til --- README.md | 3 ++- ...-different-commits-between-two-branches.md | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 git/list-different-commits-between-two-branches.md diff --git a/README.md b/README.md index 84f39c1..86421b7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_452 TILs and counting..._ +_453 TILs and counting..._ --- @@ -117,6 +117,7 @@ _452 TILs and counting..._ - [Intent To Add](git/intent-to-add.md) - [Interactively Unstage Changes](git/interactively-unstage-changes.md) - [Last Commit A File Appeared In](git/last-commit-a-file-appeared-in.md) +- [List Different Commits Between Branches](git/list-different-commits-between-branches.md) - [List Filenames Without The Diffs](git/list-filenames-without-the-diffs.md) - [List Most Git Commands](git/list-most-git-commands.md) - [List Untracked Files](git/list-untracked-files.md) diff --git a/git/list-different-commits-between-two-branches.md b/git/list-different-commits-between-two-branches.md new file mode 100644 index 0000000..6303fce --- /dev/null +++ b/git/list-different-commits-between-two-branches.md @@ -0,0 +1,24 @@ +# List Different Commits Between Two Branches + +There are times when I want to get a sense of the difference between two +branches. I don't want to look at the actual diff though, I just want to see +what commits are on one and the other. + +I can do just this by using the `git-log` command with a couple flags, most +importantly the `--cherry-pick` flag. + +To compare the `feature` branch against the `master` branch, I can run a +command like the following: + +``` +$ git log --left-right --graph --cherry-pick --oneline feature...branch +``` + +This lists commits with the first line of their messages. It also includes +either a `<` or `>` arrow at the front of each commit indicating whether the +commit is on the left (`feature`) or right (`master`) branch, respectively. + +Note: you can use more than branches in a command like this. Any two +references will work. You can just use two SHAs for instance. + +[source](http://stackoverflow.com/questions/7566416/different-commits-between-two-branches)