我想查看两个分支之间仅包含非常见提交的列表。
我怎样才能得到这样的输出?
基本上是一个 git diff -y master new-feature
两个分支之间的总结:
master new-feature
-------------------------------------|--------------------------------------
xxx - Jan 1st 2018 - initial commit | xxx - Jan 1st 2018 - initial commit
xxx - Feb 1st 2018 - fix a bug | xxx - Feb 1st 2018 - fix a bug
> xxx - Mar 1st 2018 - WIP almost done
xxx - Apr 1st 2018 - fix another bug | xxx - Apr 1st 2018 - fix another bug
xxx - May 1st 2018 - fix more bugs | xxx - May 1st 2018 - fix more bugs
> xxx - Jun 1st 2018 - Ready to merge!
xxx - Jul 1st 2018 - latest patches <
解决方案 : 我不知道如何让它正面或反面,但我认为
git log --graph
实现了这一点,只是具有非常困惑的视觉风格:git log --left-right --graph --cherry-pick --oneline master
或这个?
更好的是,
git diff -y --suppress-common-lines master new-feature
是我真正想要的: master new-feature
-------------------------------------|--------------------------------------
> xxx - Mar 1st 2018 - WIP almost done
> xxx - Jun 1st 2018 - Ready to merge!
xxx - Jul 1st 2018 - latest patches <
解决方案:您可能无法单独使用 git,但是,根据 @torek's answer ,您可以通过
git rev-list
到达那里:git rev-list --left-right master...new-feature
>eb57618eed654685a7999da847628dc5eb27313f
>0da0196ab24542a1a1697b1c0c5efeef6d09e027
>9452f57d97e5fc86e773e7a9fca488b7a0d44a0c
<4fc12fe25a127f8f0dfddf7625c22656c7b2c7c1
<9c0058dcabacfc6560f4fbaf73ea55dd70d27036
>5117fcd041793898683f9469aac00337e9fadd8b
或者甚至只是这个?
比这更重要的是
git diff --right-only master new-feature
样式 View 将完成工作: commits only in new-feature
-------------------------------------
xxx - Mar 1st 2018 - WIP almost done
xxx - Jun 1st 2018 - Ready to merge!
当然,可以颠倒过来以获得相反的 View
git diff --right-only new-feature master
commits only in master
-------------------------------------
xxx - Jul 1st 2018 - latest patches
解决方案 : 作为 @brentjanderson points out ,
git log master..new-feature
和 git cherry -v master
两者都这样做:git cherry -v master..new-feature
+ c00335cd93898683f9469aafad8a8476227b117f WIP do things
+ f5c86e777d97e5f3e7a9fca488b79a0d44ac9452 WIP do more
+ 0ef6ddda576180196ab7b1c0c57eefe009e027dc Finished!
也
git log master..new-feature --format="%h - %ad - %s" --date=format:'%b %d %Y'
c00335cd - Jan 01 2018 - WIP do things
f5c86e77 - Feb 01 2018 - WIP do more
0ef6ddda - Mar 01 2018 - Finished!
附言我试过
git checkout new-feature; git log --left-right --graph --cherry-pick --oneline master
之前,但我无法对输出做出正面或故事(或反面)。实际上,再想一想,我敢打赌,将输出转向侧面,然后将其作为 excitebike map 进行播放,这将是一个很好的故事。唔...
最佳答案
这是一个没有花哨格式的基本变体:git log master..new-feature
您可以通过交换分支的顺序来获得“左侧”或“右侧”数据:git log left-side-branch..right-side-branch
这也适用于其他引用(提交哈希、远程分支、标签)。
要获得所需的完整日期格式:git log master..new-feature --format="%h - %ad - %s" --date=format:'%b %d %Y'
这不会做序数日期( Mar 1st 2018
是 Mar 01 2018
)因为 strftime不支持。如果这是一个硬性要求,我建议编写一个批处理脚本。
关于git - 如何获取两个 git 分支之间不同提交的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53107027/