每次合并分支后,为什么git log图又增加了一行? [英] Why does my git log graph grow one more line after I merge a branch each time?
问题描述
我曾经使用 git log --oneline --graph --decorate --all
作为别名 git ll
来查看终端中的提交图
I'am used to use git log --oneline --graph --decorate --all
as alias git ll
to see the graph of commits in terminal
但是,每当我将我的 develop
合并到 master
时,一个问题就使我感到困惑.上面命令的输出可能是这样的:
But a problem confuse me when every single time I merge my develop
to master
.
The output of the command above may be like this:
* 0d1bf7b (HEAD -> master) Fix typo
* f843224 Merge 'develop' to 'master'
|\
* | d673b76 (origin/master) Remove console.log for license information
* | 5080afc Remove all http url in production
* | f28e74b Merge branch 'develop'
|\ \
* \ \ 75c5b90 Merge branch 'develop'
|\ \ \
* \ \ \ ec189e6 Merge branch 'develop'
|\ \ \ \
* \ \ \ \ eb79c75 Merge branch 'develop'
|\ \ \ \ \
* \ \ \ \ \ 74631ef Merge branch 'develop'
|\ \ \ \ \ \
| | | | | | | * f7a4155 (light) Fix typo
| | | | | | | * 1d6c411 Merge 'develop' to 'light'
| | | | | | | |\
| | | | | | | |/
| | | | | | |/|
| | | | | | * | 3715f47 (develop) Finish GroupCard in Setting page
| | | | | | | * e606e68 (origin/light) Remove console.log for license information
| | | | | | | * 676774c Remove all http url in production
| | | | | | | * c1bef16 Fix api url error
您可以看到将 develop
合并到 master
后生成的行太多.目前,这不是什么大问题,但是它将有太多的行阻碍我到某一天查看提交.
You can see there are too many lines generated after I merge develop
to master
. It is not a big problem for now, but it will become too many lines too obstruct me to see the commits someday.
那么我有什么事做错了吗?你们曾经遇到过这种问题吗?您如何处理?
So is there any thing I do wrong? Have you guys ever faced kind of this problem? How do you handle it?
谢谢你们.感谢您的回答.
Thank you guys. I appreciate your kind answers.
我想解决我的问题并将其澄清一点.我使用了一些GUI工具,例如Source tree,它显示了git日志,如下所示.如您所见,该图中没有很多具有相同存储库的复杂行.
I want to fix my problem and make it clear a little bit. I use some GUI tools like Source tree and it show the git log as below. There are not many complicated lines with the same repository in this graph as you can see.
那么我是否可以在命令行界面中显示类似的图形呢?
So is it possible if I want to show the graph like it in my command line interface?
推荐答案
That is why squash and rebase do exists (for local commits of develop you have not pushed yet).
That would help keep the history linear, instead of git log showing you each develop merge in its separate track.
那么我是否可以在命令行界面中显示类似的图形呢?
So is it possible if I want to show the graph like it in my command line interface?
In command-line, you can avoid all those extra lines by adding --no-merges
:
git log --decorate --oneline --graph --no-merges --all --branches
这篇关于每次合并分支后,为什么git log图又增加了一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!