5 ms·
This is ugly and pollutes your history graph across branches. After all, a merge should only occur to merge a finalized branch in. This sounds like a completel
by barrkel 12y ago
This is ugly and pollutes your history graph across branches. After all, a merge should only occur to merge a finalized branch in.
This sounds like a completely arbitrary rule to me. I just don't get why people try so hard to avoid merges, and instead go down the rebase route.
Rebasing isn't just a pain, it's rewriting history. It's potentially dangerous in a team environment. You can't distribute your rebased branch without a force push, and that risks two versions of the branch's commits getting into the repository, or losing someone's commits altogether. It's usually not worth the effort.
It also presumes a simplistic development environment. Typically, I see branches that fit into categories; let's name them master, develop, small-feature, big-feature, next-gen-architecture.
Small-feature branches can be rebased fairly easily. There's not many commits, they're most likely worked on by a single person so the history isn't distributed, and replaying the commits isn't too onerous.
Big-feature branches are a little more tedious. This is where rebasing starts to become a pain; the big feature may have touched code that has since changed from commits of a few small-feature branches.
Next-gen-architecture is where it all falls apart. Trying to do a major refactor while simultaneously keeping customers happy with smaller features is a fact of startup business, if not most businesses. Rebasing becomes a multi-hour exercise because there are hundreds, if not thousands of commits to replay. And everyone on the team has this branch, and there may be sub-branches of it that are destined to be merged into it. All the sub-branches need to be rebased too.
- dankohn1 12y agoWe've had good success encouraging daily merges of master into feature branches, and then using `git merge --squash` to avoid hopeless polluting of your history graph. Git merge squash essentially takes a diff of your feature branch and master and applies the diff as a single commit. See http://stackoverflow.com/a/25387972/1935918 http://stackoverflow.com/a/25387972/1935918 You lose the history of the feature branch, but we don't want that history anyway, since once tests are passing and the branch has been reviewed, we treat it as an atomic unit. That is, we might revert the whole commit, but we're not interested in reverting part of the commit.
- rtpg 12y agoDoesn't this make commits too big? On the team I'm working with right now, most people are making really small commits, but it makes git's history mechanism really useful. A single line change can be linked to a relatively small commit, it's extremely useful to figuring out the "why" of something. Having one commit for an entire feature would make that utility completely disappear
- dankohn1 12y agoYes, the downside of aggregating history is that you've aggregated your history. So far, it has worked well for us, partly because we try to keep feature branches small.
- BetaCygni 12y agoRebased fixes are easier to audit, so I can see an open source project preferring them. Otherwise, just freely merge to/from trunk. Prevent criss-cross merges though, those are a pain.
- maaaats 12y ago> This is ugly and pollutes your history graph across branches. After all, a merge should only occur to merge a finalized branch in. >> This sounds like a completely arbitrary rule to me. I just don't get why people try so hard to avoid merges, and instead go down the rebase route. I agree, I think that graph looks fine. I often end up with this, not just to avoid a big merge later, but because functionality I'm working on can benefit or depend on other work done on the main branch.
- DougWebb 12y agoI always do my work on a branch, switch to master when I want to pull, and rebase my branch on the new master. If I'm working on a feature branch that other developers are also working on I do the same thing with the feature branch; my local work is on a local branch that I rebase onto the tip of the shared feature branch. When I want to share my commits, I do my rebase first, do a fast-forward merge in the shared branch (with or without a merge commit, depending on whether or not I need to group my commits), and then I push the shared branch. After that my local branch is rooted at the tip of the shared branch, and prior history never gets rebased again. Merging master into a shared feature branch requires different techniques; we don't use rebase for that. Instead we coordinate: everyone gets their work into the feature branch (or takes responsibility for anything they're not ready to commit yet), and one person takes on merging master into the feature branch, fixing conflicts, and pushing the result back to the shared branch. Everyone else pulls, rebases any local work they still have, and we move on. When it's time to merge the feature branch into master we do the same thing, but no local work is allowed to be held back, and the person doing the merging will also merge the final feature branch back into master. Luckily I'm in a small company with not too many developers. I can see the coordination required for what I just described getting more and more difficult as the branches get bigger, last longer, and have more people working on them. When you get up to that scale the Linux Kernel approach of breaking the project into largely independent sub-projects with different owners responsible for merging their own parts is probably the best approach. That makes the coordination manageable.
- e40 12y agoRebasing isn't just a pain, it's rewriting history. I'm so tired of this!! Of course you never rewrite history on a public branch!! Of course rebase is fantastically helpful on a private/feature branch where you are doing development, before you do your final push to the public branch!! Can we stop with these tired, old tropes please??
- Kiro 12y agoSorry for OT but even if you have a point it's hard to take your comment seriously when you end every sentence with double exclamation or question marks.
- e40 12y agoWell, it was for emphasis. I can't count how many times I've seen the "rebase is evil" trope. It's so tired and abused and annoying and misguided. So, yeah, the sentence terminators were to convey the very real emotion on this subject.
- smeyer 12y agoThe point of the previous commenter is that even if it's to convey very real emotion, it makes your comment harder to take seriously and actually lessens the impact of it.
- barrkel 12y agoWhat do you mean by "public branch"? Public to the team, or public to the whole world? I do commercial closed-source development; there is no public branch to the whole world. OTOH, all feature branches are public to the team; only trivial features involve a single developer. So your assertion doesn't seem well-formed to me. Further: The distribution of code and feature responsibilities in a team of full-stack engineers is fluid. Depending on the day, any person might be working on a feature, and the person previously working on it might not even be in the office. It's a general policy where I work to push your branches before close of business.
- Gmo 12y agoTotally agree. It almost looks like you are my colleague ;-) At any point, we have at least 3 different feature branches, which can be relatively long running (minimum 1 week), this is because we have a range of products sharing the same base platform. So when come merge time, well ... we merge and do not rebase master before doing that (well, technically we merge on an RC branch but that still applies). If we would rebase, we would have 2 teams that need to go through a potentially painful rebase process. Besides, on each branch, there are usually at least 2 developers, so it would be even more chance to have a problem for the developer that is not doing the rebase. Well, all of that to say that we just do a merge (with no squashing ...I really dislike a big commit, even more if it shares some frontend and some backend stuff in the same commit).