Merge GIT branch without commit log

As mentioned in "Trimming GIT Checkins/Squashing GIT History", if your commits c and e were done with a comment prefixed with fixup!, then the rebase --interactive --autosquash (git1.7+, February 2010) can do exactly what you are after.

with the fixup! directive, you could keep that squashing "invisible" in the commit message, while still benefiting from the automatic commit reordering with the --autosquash option.

To commit with a fixup! prefix, you can define the alias

[alias]
    fixup = !sh -c 'git commit -m \"fixup! $(git log -1 --format='\\''%s'\\'' $@)\"' -
    squash = !sh -c 'git commit -m \"squash! $(git log -1 --format='\\''%s'\\'' $@)\"' -

The fixup alias would then apply for those "commits (which) are just save points, i.e. not that important in the grand scheme of things".


There is, but it is nonsense. Why do you want to do that? You'll lose all branch history and information.

You could use g's commit message for your merge commit and then browse history with the --first-parent option.

If you really want to lose history from your branch use git merge --squash, i do not recommend it though

Edit

In case you are not happy because you do not consider your history very clean, you can use Git's rebase feature:

You can retroactively edit old commits and create new commits from your existing branch (in effect rewriting it). It allows you to reword commit messages, split commits, squash commits into a single commit, re-order commits, etc.

You should only use rebasing when you haven't published your branch (i.e. it is only a private branch), because it will give other developers headache and could cause merge problems later on, if someone kept working on the old (before rebased) branch.


I consider merge --squash extremely useful when I use a "branch per feature" approach. My commit history in temporary branches is a complete garbage, absolutely meaningless. And I really want to be unable to see that history anymore, not just to be able to skip it.

When the commits go to code review, it is important not to create extra commits.

Tags:

Git

Merge