3 ms·
This sounds like horrible advice. Especially the part about git bisect: it is indeed an often situation, where both feature branch changes and master branch cha
by golergka 11y ago
This sounds like horrible advice. Especially the part about git bisect: it is indeed an often situation, where both feature branch changes and master branch changes are correct by themselves, and only introduced the bug when combined. And in this situation, git bisect pointing to the merge commit as culprit is exactly what should happen, because incorrectly implemented merge, which didn't take care of interface changes (for example), is exactly the reason for such a problem.
This exact situation is also the reason why I hate git rebase: it rewrites history and hides it's real complexity under leaky abstraction. When I tried to use it, I found myself guessing a few months later: were these commits really how I (or a team member) wrote this code? Or may be these are actually rebased commits?
So, this statement:
> having the history linear without any merge commits could immediately point out the commit that causes issues.
Is laughably incorrect. When you make your history linear, you can no longer pinpoint the commit that caused issue, because after doing rebase, you destroyed it. The original commit that caused the issue is no longer there. Or, it never was there: if the issue was introduced not by individual change set A or B, but by there combination, then the merge commit would the one that caused the issues. But since you did rebase instead, the `git rebase` command was the "commit" that caused your issues! But, of course, you won't see it in git's history.
- justicezyx 11y agoUnless we live in some parallel universe, everything is linear... I think you simply miss the idea of linearizability...
- CrystalGamma 11y agoWell people work concurrently, and IMO the repository should show that, too.
- golergka 11y agoThe work of several people who are active at the same time cannot be linear by definition.
- justinjlynn 11y agoI must respectfully disagree. In this universe, nothing is linear in terms of how we perceive events and their simultaneity. If we consider a commit is an event, then who can say one commit comes before another? As in relativity, if both developers are working independently then they each of their own frame of reference. In effect, a merge commit reconciles those different frames of reference in its own discrete and well-documented entity. You could think of it as the equivalent of a Lorentz transformation. I understand the analogy is quite stretched here, but I still find it useful. It follows then that if a merge commit is a genuine reconciliation, then a rebase is the act of one party rewriting their own memory in order to hide from themselves the fact that they were working in isolation and later had to agree on the actual outcome of events. Thus, in effect, rebasing ones code is no different than suffering from a self-inflicted delusion. That is, a delusion that we are all working in one shared directory or, to a lesser extent, that there is one source of truth as in SVN or other centralised systems. This is, in fact, quite a sad thing our community. Many a developer -- while they may be using git -- are not truly using git in the way it was intended. They have limited themselves to their old ways of thinking and acting and, in the pursuit of what they have been taught is "the ideal", they have hidden from themselves the possibilities, efficiencies and understanding that might be discovered by the move into a world which can capture the fact that not everyone works in a single shared directory with immediate knowledge of each other's work. We have to learn to embrace the oddity of a non-linear history because, while we might not like it, it represents what really happens when we write code. The better our tools help us model reality the better answers we can produce for ourselves now and in the future. Six months from now when we say, "How the hell did this ever work?" or "What the fuck was I thinking when I wrote that?", we'll want answers. If we choose rebase, corrupt our own memories and burn the reflogs we'll never know.
- Pyxl101 11y agoThis is a poor and incorrect analogy for rebase. Someone using rebase is conducting the reconciliation and then rewriting their commit to account for it, while simplifying the commit history and hiding it. When a commit lands in master, it doesn't matter to anyone else how it was developed. Those events are almost outside the "light cone". Those who rebase a commit onto the upstream branch recognize that the little details of how it was made have no relevance to others and thus do not belong in shared history. People often speak about preserving history while missing the point that source history is most meaningfully logical, not physical. Imagine an editor that made a new commit for every key press. That would be a true recounting of history, and yet would be irrelevant. Most feature development can and should land as one commit; the details of how it was made are, like the key presses that composed it, minimally relevant to anyone but the author.
- jack9 11y ago> Is laughably incorrect It depends on your workflow. It's correct in context. Don't rebase. You see the commit that caused the breakage if you have a testsuite-on-commit workflow.
- golergka 11y agoBut you will have to either merge or rebase if someone else pushed into master while you were working. The difference is, rebase keeps the history honest about the fact that you were working concurrently, while rebase tries to construct an alternate, false version of these events.
- yxhuvud 11y agoThe interesting part of a commit is not when you did something, but how it will change the repository.
- Pyxl101 11y agoRebase also doesn't change when you did something either.
- golergka 11y agoBut "how it will change the repository" depends on "when" did you change something, e.g. parent commit.
- yxhuvud 11y agoYes, which is why you want a straight history so that it is obvious that no shenanigans had to happen in the merge commit.
- jack9 11y ago> rebase keeps the history honest The history is a record of changes. You're suggesting there's a good reason to track timeshifting by implication (you could rebase at multiple points) because...honesty? I'm not trying to argue about the why. I'm trying to understand the why. My view is that you merge your change into the head and there's a record. That's the story. The particulars of how a particular commit came to be is irrelevant to the repo and less problematic when it's treated the same as any other commit.
- karyon 11y ago> git bisect pointing to the merge commit as culprit is exactly what should happen in theory, maybe. in practice, this simply does not help if you are looking at massive merge commits. sometimes, the merge goes wrong even with no conflicts, and then you can debug that massive merge with little clue where to start. compare that to rebasing, where you have a hopefully small commit that breaks. you indeed loose the information whether the rebase broke it or the initial version was broken as well, but I don't see the practical difference, it needs to be fixed either way.
- golergka 11y agoBecause the notion that commit broke that code is false, and out of that false information you will be able to get a lot of other false ideas about how the code was developed, which will lead to your fix not being entirely correct.
- karyon 11y agoThat notion is false, right, thus I'd rather think "this commit is not correct anymore". Regarding getting ideas how the code was developed, for the commit that is not correct anymore I have a commit message telling me why it was added. For reasonably small commits, I don't a lot of room for misunderstandings and wrong fixes. This applies if the required changes in your branch are rather small. I think we can agree that rebasing breaks if some changes in master require lots of changes in your branch. But so does merging, as the merge becomes even more horrible and error-prone in that case. Basically, large changes ("real" development) should happen neither in merge commits nor during rebases in my opinion.
- golergka 11y ago> I'd rather think "this commit is not correct anymore" Using the word "anymore" violates the whole abstraction of git, which captures the exact state of the project in each commit. If you look at a commit, there's no "anymore", no other timeframe rather that the commit's; it's either correct or incorrect on it's own. > But so does merging, as the merge becomes even more horrible and error-prone in that case. Why? Just as you don't put all your feature work in one commit, why would you implement a complex merge as one, single merge commit? It makes much more sense to merge each interface change from master to feature branch individually, resulting in atomic merge commits, each of which handles specific aspect, while staying correct.