简体   繁体   English

仅通过合并基础和合并提交过滤 git log

[英]Filter git log by only merge-base and merge commits

My git repository has multiple branches.我的 git 存储库有多个分支。 I'd like to see a branch graph which describe how these branches divided and merged.我想看到一个描述这些分支如何划分和合并的分支图。

Consider this graph:考虑这个图:

$ git log --graph --all --oneline
*   eac03d9 (develop) Merge branch 'release/xxx' into develop
|\
* \   d94a368 Merge branch 'feature/xxx' into develop
|\ \
| * | 624b398 feat: xxx
| * | 9a87641 feat: xxx
| | | *   6bfbc30 (master) Merge branch 'release/xxx'
| | | |\
| | | |/
| | |/|
| | * | 8d85380 (release/xxx) fix: xxx
| | * | f7e9ef9 fix: xxx
| |/ /
|/| |
* | | 733751e feat: xxx
* | | d5efb9e feat: xxx
|/ /
* | 5ceb217 feat: xxx
* | ea70adf feat: xxx
* | eeff2a3 feat: xxx
|/
* b4b3db0 root

It contains many feat: xxx and fix: xxx commits, which i'd like to hidden.它包含许多feat: xxxfix: xxx commits,我想隐藏它们。 I'm looking for some git log options to filter only merge-base and merge commits.我正在寻找一些git log选项来仅过滤合并基础和合并提交。

For example:例如:

*   eac03d9 (develop) Merge branch 'release/xxx' into develop
|\
* \   d94a368 Merge branch 'feature/xxx' into develop
|\ \
| | | *   6bfbc30 (master) Merge branch 'release/xxx'
| | | |\
| | | |/
| | |/|
| | * | 8d85380 (release/xxx) fix: xxx
| |/ /
|/| |
|/ /
|/
* b4b3db0 root

I guess this should work for you.我想这应该对你有用。
git log | grep -vE "[a-zA-Z0-9] feat: xxx|[a-zA-Z0-9] fix: xxx"


Explanation :解释 :

1) 1)
| -> Pipe will provide output of command at the LHS to RHS -> 管道将在 LHS 向 RHS 提供命令输出
Example : git log | grep "fix"示例: git log | grep "fix" git log | grep "fix" will provide output of git log to grep command git log | grep "fix"会将 git log 的输出提供给grep命令

2) 2)
grep -vE -> v for avoiding / excluding , and E for adding more arguments within single grep (or I can say it as or , that is grep "a|b" means show output if there is a or b grep -vE -> v 用于避免/排除,E 用于在单个 grep 中添加更多参数(或者我可以说它为or ,即grep "a|b"表示如果有ab则显示输出

3) 3)
[a-zA-Z0-9] -> is a regex to avoid special character (see here : https://regex101.com/r/DXmsTi/1 ) [a-zA-Z0-9] -> 是一个避免特殊字符的正则表达式(见这里: https : //regex101.com/r/DXmsTi/1


Update:更新:

git log |  grep -E " Merge branch |\(release/"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM