问题
I'am used to use git log --oneline --graph --decorate --all
as alias git ll
to see the graph of commits in terminal
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
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?
[Editing on 2019/05/20]
Thank you guys. I appreciate your kind answers.
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?
回答1:
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
回答2:
Of course you should use rebase and squash wherever applicable. Additionally, you can try following --no-merges option like:
git log --oneline --graph --decorate --all --no-merges
来源:https://stackoverflow.com/questions/56178711/why-does-my-git-log-graph-grow-one-more-line-after-i-merge-a-branch-each-time