I have a project where I am the only developer, with develop and master branches. Every time I merge develop into master, I'm getting an extra merge commit. I think this is because it is not doing a FF merge for some reason. But the code in the develop and master branches is identical. I'll add a new feature to develop branch, often one commit, then after testing merge it to master. And every time I'm getting these extra commits (which also makes develop branch look like it's 15 commits behind master).
I have a few other projects I'm running the same way, and I'm not getting the extra commits on those. So it appears I've done something to this project to cause it to create these extra merge commits every time. Any idea how to stop getting these extra commits? I've done everything except blow away the develop branch and create it again from current master.
Bonus question, is it possible to clean up the history by essentially removing the merge commits without squashing or removing the additional commits accompanying them? I've considered blowing away the MASTER branch and creating it again from develop (since it doesn't have the extra commits) but I'm not sure that's a good idea.
You can only fast-forward master
to develop
if develop
is "based" on master
(by going back from the commit develop
points to it should be possible to reach the commit master
points to).
Looking at the picture, it is very likely that at the moment master
points to 28b73893
but develop
is still at aeb743f1
. If you make a commit in develop
, the fast-forward will not be possible.
To solve that, merge master
back to develop
. This will be a fast-forwarding merge. After that, master
and develop
will point to the same commit; and it will be possible to make a commit in one branch and fast-forward the other branch.
You need to use the rebase command.
If you want the history of your branches to look linear, what you want to do is:
git commit -m "FeatureX on Dev"
git fetch origin master:master
, git rebase master
git checkout master
, git rebase Development
, git push -f
PS: Rebase
is dangerous since it rewrites the history of the branch (steps 2 and 4 above), unless:
For both, you should be good.
Specific to Azure-Devops:
Under Repo->Commits, if you click on the filter icon and choose "First Parent", it will hide the merges automatically. Try and see if Github has the same?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With