mirror of
https://github.com/jbranchaud/til
synced 2026-01-04 23:58:01 +00:00
Add List Different Commits Between Two Branches as a git til
This commit is contained in:
24
git/list-different-commits-between-two-branches.md
Normal file
24
git/list-different-commits-between-two-branches.md
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user