Clean master branch but also detailed record of intermediary commits
Goal: keep a clean history of master, whilst also keeping the intermediary commits.
For instance, let’s start with a master branch:
- How can I preview a merge in git?
- Git: git diff show changes, but merge says up to date?
- How to merge branch of forked repo into master branch of original repo?
- How to rebase off master with github client?
- Issue when merging a Git subtree when a file has been removed
- Merge conflict error, when there was no change in mentioned file
M1 --- M2 --- M3 ^ master
I work on a feature/bug/whatever on a new branch:
M1 --- M2 --- M3 ^ \ | \- F1 --- F2 -- F3 | ^ master feature
And when I merge into master, I want
M3 to be the parent, but also keep the “iterations” you took to reach from
M3 to the new commit. This can be done with
M1 --- M2 --- M3 ----------------------- M4 \ / ^ \- F1 --- F2 -- F3-/ master ^ feature
Which is almost what I had in mind. The problem I have is that for git, as far as I can tell, both
F3 are “equal” parents of
M4, now both part of branch
What I want is to be able the show (with
git log) the master branch without the feature branch (
F1-F3) to have a cleaner view over the branch. ideally this would be default. But also be able to show the
F3 commits to view the more “detailed” history when needed.
Is there a way to have this, or something close to this in
One Solution collect form web for “Clean master branch but also detailed record of intermediary commits”
git log --first-parent master
To quote the manual
Follow only the first parent commit upon seeing a merge commit. This option can give a better overview when viewing the evolution of a particular topic branch, because merges into a topic branch tend to be only about adjusting to updated upstream from time to time, and this option allows you to ignore the individual commits brought in to your history by such a merge.