5 ms·
> Who do we really help by pretending that we're more organized, coherent, and linear than we actually were? We're helping the future reader who's reading the
by nemetroid 6y ago
> Who do we really help by pretending that we're more organized, coherent, and linear than we actually were?
We're helping the future reader who's reading the history because they want to understand why a change was made - and "because the author of the branch initially had the wrong idea" is almost never the answer they're looking for.
I sometimes enjoy reading stream-of-consciousness writing, but most of the time (especially when reading code) I'm more interested in the point itself. The same applies to version history. It can be used to tell the raw story, but there's usually a more useful and interesting story to be told.
- acemarke 6y agoExactly. I want to "tell a story" with my commits, and that story is really more of an idealized retelling of what I actually did. Five years from now, no one needs to know that I forgot to add that one line to a prior commit and had to add it separately, or that my first attempt didn't quite pan out as expected. What that future person _will_ care about is: - What final changes actually got made? - What task was I working on? - What was the reason for any of these changes in the first place? - Why did I make some of these changes specifically to implement that task? - What additional side info is important context for understanding the diffs?
- SamBam 6y agoExactly. It's also great to compartmentalize different aspects of your change. Often my changes are 1. Refactor the existing code to support the new feature 2. Add the new feature It's great to keep these separate, because someone can look at number 1 and see that the two versions of the code ought to be functionally the same (same tests pass, app looks the same, refactor is easy-to-understand), and look at number 2 and see the new feature. There are countless other times where you want to tell the "story" in a logical fashion. (Honestly, I expect that there is a significant correlation between being a good git committed and being a clear story-teller.)
- gmfawcett 6y agoI understand that you want to tell a story. But as someone examining your code, I also want to know how you got there. While you're throwing out your junk, you're also throwing away valuable information. If I'm taking the actual time to review the code history, then let me play it out in real-time, mistakes and all. I know how to step back and summarize, I don't need you do do that for me. This is especially true if your code is clever. I'm much more likely to understand your polished gem if I can see all the things that you bumped into while you were discovering it.
- mathstuf 6y agoThat is what comments and commit messages are for. I trawl history all the time. Running into an unbisectable mess of a branch (because a bug that was introduced in commit X~15 is fixed in X on the same branch) is a complete nightmare. I have to discect the branch history and understand what is because of the branch and what is debugging/review/CI cycle cleanups. Commit messages for fixups also tend to be 100% terrible and utter trash. "Fix review comments". Thanks. If we're doing that, let's copy what the comment was in too and why it fixes it. The problem with your request is that 90+% of the time (with the way I develop), the dead ends are on MRs that got closed or code that never got pushed in the first place. So again, comments as to why this approach is used is way better than hiding it in the history because someone coming to "clean up" code sees the thought process instead of having to remember to search for it.
- gmfawcett 6y agoI don't do much work like that -- I suspect you're part of a much larger developer team -- but I think I understand the problem you're describing. Couldn't you simply review/bisect at the fork/join points? i.e., take the commits at which forks began or ended, ignore any intermediary commits, and run the bisect (or, read diffs) across that subset? That way you're only comparing at the chapter-markers of the story, so to speak, and not getting mired in the gory details.
- mathstuf 6y ago
- fiddlerwoaroof 6y agoThis is great, except that we’re often bad at recounting this idealized history without lying in ways that make later maintenance more difficult
- fao_ 6y ago> or that my first attempt didn't quite pan out as expected. Actually that's still important, it's just important from an architecture perspective.
- zoomablemind 6y ago> We're helping the future reader who's reading the history because they want to understand why a change was made... "Change" is a subject to interpretation. Most of the time it's the scope that the change belongs to is what has the meaningful value. Say, changes made in connection to fixing an issue are logically tied for inclusion as well as for potential unwinding. Some tangent changes technically should not be casually folded in, just in case this changeset will need to be propagated or rolled back. Thus this elaborate muli-staged commit management in Git. Many projects don't have such need to manange the change flow, so Version control is used as a kind of undo buffer. Which is fine, in such cases the meaning is tied to release states. If anything, it makes more practical sense to preserve only commits with a buildable state, not just some transitional changes.
- Wowfunhappy 6y agoAs a much newer developer, the biggest problem I have with git is that I rarely end up actually making one change at a time. I'll be working on some larger thing, and in the process I'll notice and quickly fix a smaller thing before returning to the original task. This might be a typo in a code comment, a poorly named variable, or a block of code I realize is dead. I suspect this is the type of tendency which goes away with experience, but it makes git a lot less useful. My commits won't really tell you what changed; the most they can tell you is the primary change I was working on.
- FrancoisBosun 6y agoThat is what OP was talking about: after you've done the change, make a commit with just that tiny refactoring. Once you're done and ready to review your work, you can cherry pick just that fix and move it to main / master / it's own PR. Since it is self-contained, it can be processed by itself only.
- gmfawcett 6y agoMany of us do that, and it's not just a new developer thing. Git actually enables this, because you get to pick and choose what to add to the index (`git add`) before committing. So that little tweak you made in the unrelated function? -- no problem, just `git add` that later, and commit it under a different message. Not all SCM tools give you that kind of flexibility. On the other hand, there's a diminishing return to placing every tiny change into a separate commit. Commit messages like "Fixed multiple small things" might make some people clutch their pearls, but sometimes you just need to get shit done and move on to solving bigger problems. My suggestion is to consider breaking your commit into two: one for "fixed this big issue that everyone cares about", and one for "a bunch of tiny cleanup stuff that I happened to notice." (Maybe call that second one "refactoring" -- it will go over better with your audience.)
- Wowfunhappy 6y ago> Git actually enables this, because you get to pick and choose what to add to the index (`git add`) before committing. That assumes the changes are in separate files though, right? I know you can do use the "-i" flag, but it's fairly labor intensive.