Reputation: 3085
if another developer branches out on branch DEVELOPER_A, and makes a lot of commits on that branch, when he's done, I want to merge his work onto master. but I don't want all his small commits to show up on the master branch history, and only care about the last commit. so is there a way to "squash " his history on branch DEVELOPER_A when merging that branch?
I could get a patch on developer_A branch, and apply to master, but I'm afraid git will lose track of the fact that the result is merged from developer_A branch, and merely thinks that this is some independent change
Thanks Yang
Upvotes: 1
Views: 193
Reputation: 11791
Most of the time you want to clean up the history, not just mush everything together. The tool for that is git rebase (use with extreme care, and never on published stuff, as changing history creates havoc for your downstreams).
OTOH, it is very useful to have a detailed history (micro-commits) at hand for chasing bugs (look at git bisect).
Upvotes: 0
Reputation: 84343
You can do this in several ways, but the most obvious is to use a squashed merge.
git merge --squash <other_branch>
git commit
Note that git will pre-populate your merge commit message with the log messages from the squashed commits, but you are free to edit or delete the messages to suit yourself.
Upvotes: 3