I have here a git repository with a few people working on it.
I’ve set up branch.master.rebase = true and branch.master.mergeoptions = --no-ff, but I have came across a problem:
Someone tried to merge a feature branch into master. The merge was successful, and git said the branch was 30 commits ahead of origin/master. When he tried to push the changes, git rejected the push because there where changes in the remote, so he had to git pull. When he did the pull, git made a rebase for the commits that where merged into master, and now it was only 29 commits ahead of master.
I believe the merge commit was lost, because after the rebase, the commits where reapplied as new commits, and not commits that came from the feature branch.
After the push, the tree was like that:
* c3'(head, master, origin/master)
* c2'
* c1'
| * c3 (feature_branch, origin/feature_branch)
| * c2
| * c1
| /
*
That is what I was trying to achieve:
* c4 (head, master, feature_branch, origin/master)
| \
| * c3 (origin/feature_branch)
| * c2
| * c1
| /
*
The merge looked like a fast-forwarding merge, what I’m trying to avoid, to keep branching history.
Any tips on what I can do to avoid this?
Thanks,
Edit:
This article descibes my problem:
http://notes.envato.com/developers/rebasing-merge-commits-in-git/
Now I’m aware of the –preserve-merges option for git rebase, but is there a way to make this option default?
Otherwise, the developers would have to git fetch and git rebase origin/master instead of just git pull.
Why do you use branch.master.rebase = true if you want to save all branching history?