You can use git cherry -v master dev
It will show commit message with commit hash.
题
The git cherry command is great for seeing what commits have happened between two branches. However, by default it just gives you a list of commit IDs - not that informative.
$ git cherry master dev # Commits in "dev" since it forked from "master"
+ 54408ddc6403376c638d5bfc94c033ab655da7b3
+ 68bc4277954b7de4c95881904de22f1d443366ae
+ d74ab86eee75a8e5c1a835a6e69e74c01d4186e8
How can I get the same list with more information?
解决方案 2
You can use git cherry -v master dev
It will show commit message with commit hash.
其他提示
You can achieve this by piping git cherry
output through two more commands:
First use sed
to remove the +
at the start of each line to leave the raw commit IDs:
$ git cherry master dev | sed 's/^+ //'
54408ddc6403376c638d5bfc94c033ab655da7b3
68bc4277954b7de4c95881904de22f1d443366ae
d74ab86eee75a8e5c1a835a6e69e74c01d4186e8
Now use xargs --max-lines=1
to pass each commit ID to git log -1
, which can then display other information about each commit:
$ git cherry master dev | sed 's/^+ //' | xargs --max-lines=1 git log -1 --pretty=format:"%h [%ad] %an : %s" --date=short
54408dd [2013-10-09] Robin Winslow : Update Binaries submodule
68bc427 [2013-10-09] Robin Winslow : Update reference dependencies for Website
d74ab86 [2013-10-09] Robin Winslow : Remove non-exisent files from Website project
Note: You can tailor the --pretty=format:"%h [%ad] %an : %s" --date=short
part to get whatever output you like from git log