Quick summary of my question
I have this git lg
output (get this alias in my "Details" section below):
* 3333333 - merge of feature branch into `main`
|\
| * ccccccc - feature branch commit 3
| * bbbbbbb - feature branch commit 2
| * aaaaaaa - feature branch commit 1
|/
* 2222222 - some other commit
* 1111111 - initial commit
I want this git lg
output:
* 3333333 - merge of feature branch into `main`
* 2222222 - some other commit
* 1111111 - initial commit
How can I do that? You might re-title this question: "how to view a git log
as if it was linear".
Details
I have this git lg
alias. It's great! Get it by running this:
# add `git lg` alias from Coderwall
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
Its output looks like this:
* 3333333 - merge of feature branch into `main`
|\
| * ccccccc - feature branch commit 3
| * bbbbbbb - feature branch commit 2
| * aaaaaaa - feature branch commit 1
|/
* 2222222 - some other commit
* 1111111 - initial commit
Here, I have labeled the two branches main
and feature
. Commits 1111111
, 2222222
, and 3333333
are either direct commits to main
, or merge commits to main
. Commits aaaaaaa
, bbbbbbb
, and ccccccc
are commits on feature
branch:
v-branch `main`
v-branch `feature`
* 3333333 - merge of feature branch into `main`
|\
| * ccccccc - feature branch commit 3
| * bbbbbbb - feature branch commit 2
| * aaaaaaa - feature branch commit 1
|/
* 2222222 - some other commit
* 1111111 - initial commit
I'd like a "bigger picture" sort of view. I don't care about the individual commits in each feature branch. I just want to see these "main" commits, whether I run git log
or git lg
:
* 3333333 - merge of feature branch into `main`
* 2222222 - some other commit
* 1111111 - initial commit
How can I do that? git lg --merges
or git log --merges
is closer, but not right. It shows this:
* 3333333 - merge of feature branch into `main`
But, what I really want is the whole linear history, with all commits directly to main
, or merged to main
. That would be as if I had a squashed linear git log
history by enforcing git rebase
+squash+fast-forward merges instead of git merge
merges.
Anyway, so how can I filter and just get this git lg
output?
* 3333333 - merge of feature branch into `main`
* 2222222 - some other commit
* 1111111 - initial commit
git merge
-style workflow, show only the unique commits someone had in their PR (Pull Request) before merging. – Soup