I've heard of "merge bubbles" with regards to Git. I'm fairly well-versed in Git, but would not consider myself an expert. I've heard some negative things about merge bubbles; what is a "merge bubble" in Git, what's wrong with it, and how can I avoid it?
A merge bubble is a "trivial merge" in Git that did not require any conflicts to be resolved. The bubble occurs in the log where the merge is displayed when you use the --graph
option. for example, if you ran git log --graph
you might see something like this:
| |
* | commit d79f3c4e129356b055c659ee5be28081c1f38aa1
|\ \ Merge: 09bf1ed 4ef9a23
| | | Author: Peter <[email protected]>
| | | Date: Wed Sep 17 17:21:07 2014 -0400
| | |
| | | Merge branch 'master' of http://fictitiousrepo.visualstudio.com/DefaultCollection/_git/fictitiousproject
| | |
| * | commit 4ef9a2387f0d4db39a6cab8ff8f531815935c305
| | | Author: Andrew <andrew@example>
| | | Date: Tue Sep 16 11:54:14 2014 -0500
| | |
| | | updated changelog
| | |
* | | commit 09bf1ed0125d77c26b5760939c125998bb046e9a
|/ / Author: Peter <[email protected]>
| | Date: Wed Sep 17 17:20:30 2014 -0400
| |
| | fixed some bugs
where the lines "bulge" out is the "merge bubble". This may seem innocuous; but many consider it much less readable than what could have happened, which would be like this:
|
* commit 09bf1ed0125d77c26b5760939c125998bb046e9a
| Author: Peter <[email protected]>
| Date: Wed Sep 17 17:20:30 2014 -0400
|
| fixed some bugs
|
* commit 4ef9a2387f0d4db39a6cab8ff8f531815935c305
| Author: Andrew <andrew@example>
| Date: Tue Sep 16 11:54:14 2014 -0500
|
| updated changelog
|
...because no merge was really required.
This generally happens when accepting a pull request by automatically merging it. Sometimes this was due to the how the "Merge Pull Request" button used to work on Github.
To avoid merge bubbles with pull requests, one strategy is to manually merge. For example:
git checkout master
git remote add remoteorigin git://remotegithost.com/remotegitrepo/remotegitproject
git fetch remoteorigin
git merge remoteorigin/remoteprojectbranch
git push origin master
To remove a recently committed merge bubble from a pull request (when you haven't pushed), one strategy is to first stash your current changes, reset your head to the commit before the bubble, pull with rebase, then push. For example:
git stash save
git reset --hard HEAD~1
git pull --rebase
git push origin HEAD
Reference: http://adammonsen.com/post/1172
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