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:

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 merge --no-ff:

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 M3 and F3 are “equal” parents of M4, now both part of branch master.

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 F1 F3 commits to view the more “detailed” history when needed.

Is there a way to have this, or something close to this in git?

  • Is rebase and merge the same thing? Why are there 2 different procedures to do one thing?
  • Git: How to convert an existing `merge` to a `merge --squash`?
  • Git: Merge a Commit into a different Branch
  • Git Rebase or Git Merge?
  • Can I ignore .css files while running >$ git mergetool?
  • .gitattributes merge driver is not used
  • your branch is behind by 2 commits
  • How to reverse apply a stash that with conflict?
  • One Solution collect form web for “Clean master branch but also detailed record of intermediary commits”

    How about

    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.

    Git Baby is a git and github fan, let's start git clone.