I see a lot of questions where people are asking how that can avoid "pointless" merge commits.
What exactly is bad about a merge commit? I find them useful, as you can see exactly where two developers started working, and where there work is merged together. It seems like rebasing, as a lot of answers suggest doing, destroys this information and you lose a lot of the project's history.
Is there something I am missing that makes a merge commit undesirable?
Some people keep a merge commit, even for a fast forward, because it keeps a very good record of when a branch was completed. These people prefer "complete and accurate" history over a "clean" history. Some people avoid merge commits, even rebasing their branches, because it keeps the history easier to read.
Their advantages are not insignificant: you know when a feature got merged in master, its much easier to revert a feature if you have a merge commit for it, much easier to generate a change log with merge commits, and you have none of the problems that pushing "cleaned up" histories will have: https://www.mail-archive. ...
In your case it should suffice to either: merge again the correct branch with your missing changes. revert the merge commit (and only the merge commit) and then merge the current branch that should have been merged in the first place.
There are two different kind of merge commits:
git pull
before trying to pushThe explicit merge commits are usually perfectly fine. You usually even enforce those kind of merge commits by saying git merge --no-ff
.
The implicit ones tent to be just noise, as the typical situation is, that one developer changed one file and afterwards another developer works on another file but forgot to pull before doing the changes, and a git pull
will implicitly merge both commits by creating a noisy merge commit. The more logical history would be simply one commit from the one author and one commit from the other author. Doing git pull --rebase
will exactly do that.
Of course there are exceptions. If both authors actually worked on the same file, it might be better to have a merge commit at this point. - But even in this case maybe a rebase might be better, as it makes the changes against the first commit more explicit and therefore less error-prone.
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