2 ms·
I notice that some people seem to care more about pretty history than about useful history. I'm not a big fan of rebasing for this very reason: it changes histo
by mcv 7y ago
I notice that some people seem to care more about pretty history than about useful history. I'm not a big fan of rebasing for this very reason: it changes history, which can misinform about what was really done. It can introduce bugs in commits that didn't initially contain them.
Though I will say that git has one big glaring problem with merge commits: they are effectively black boxes, and when you've have a big merge conflict, many git tools don't tell you how that was resolved in that merge. I recently came across a merge that wiped out some of my changes with no clear reason why. I redid that merge and there was no merge conflict at all, so it's still a mystery what happened there.
Still, rebasing has caused far more problems in my experience. It's only suitable for trivial, local cases and never on commits that have already been shared (pushed).
- mdtusz 7y agoI think a lot of the fear of rebasing comes from not fully grokking what it does, and not rebasing often enough. My workflow typically involves rebasing my local branches on master every time I switch a branch or start a work session, so typically conflicts that need to be resolved are very clear and small things (e.g. someone else adds a case to a switch statement in the same place your branch does). The biggest benefit to this that I see is that your diffs are then much more clear in what they're doing, and you have the option to update the commit message to reflect the conflict resolution if required. That said, if you have a big feature branch and try to rebase it after a month vacation, you're gonna have a bad time.
- mcv 7y agoDaily local rebase on master is really the only acceptable use I know for rebasing. It's not just after a month of vacation, but simply when your local branch has a lot of commits, that rebasing can become very painful, as you may have to resolve the same conflict over and over and over again. That must be the circle of hell where programmers end up. Basically you'd have to rebase after every single commit. That would keep it the most painless, I guess. But I can also just do a single merge and I'm done.
- AstralStorm 7y agoGit-rerere and smart merge tool like p4merge help a lot with this rebasing problem. These are essential if you work with forced rebase mode like in Gerrit. (ugh) You still have to be moderately careful and read the code again.
- bArray 7y ago> Though I will say that git has one big glaring problem > with merge commits: they are effectively black boxes, and > when you've have a big merge conflict, many git tools > don't tell you how that was resolved in that merge. I > recently came across a merge that wiped out some of my > changes with no clear reason why. I redid that merge and > there was no merge conflict at all, so it's still a > mystery what happened there. Hmm, I don't think a merge magically removes the need for testing. If I build a feature A that replaces feature B, and another programmer builds a feature C that relies on some aspect of feature B, when merging, although it will merge and compile fine, it's possible it is still broken. This is a good argument for well defined interfaces, but it's possible to see how a successful merge may not produce a successful source. As for things disappearing, I think there is some edge case where it looks like one branch deleted something after you made some change to it. Generally it's best to not have people working on exactly the same part of code. On the plus side, you have a full working history, therefore can recover :)
- mcv 7y agoThere's more to it than just knowing it's broken. I want to know why and how it happened. Of stuff needs to be tested after a merge; that's how we discovered there was something wrong in the first place. But I don't want to redo the work that I already did; I want the merge to be correct. In this case, it seems the merge did something it should never have done, and it was not clear why this happened. Still, the commits that were merged both still existed, to it was easy to redo the merge. I shudder to think what would have happened if this had been a rebase; then the original commit might have been gone.