3 ms·
> just commit everything in their working directory But that's what they've tested. I've had far more problems in the other direction, where the commit doesn't
by pjc50 5y ago
> just commit everything in their working directory
But that's what they've tested. I've had far more problems in the other direction, where the commit doesn't contain the complete set of things that it's supposed to but because all the tooling - every single IDE and compiler - is looking at the working directory not the index, I've missed something.
The index is definitely confusing for new users and users of other VCS.
> having a staging area where chunks are added piecemeal is an enormous benefit.
It would be quite fun if we could have hierarchical commits, so I could add bits to a commit without having to squash/amend. Then you'd see the top-level work item as a "commit" and the individual changes as "subcommits".
- stouset 5y agoLike I said, I’m not sold on git’s specific implementation. But breaking things into smaller, focused commits is—in my experience—a hallmark of good development practice. There should absolutely be better tooling around it, so that these piecemeal commits can be tested in isolation from one another. That’s a far better approach than just throwing up our hands and committing everything in the working tree, even if half of it has nothing to do with what’s intended.
- jefftk 5y agojj split?
- treadmill 5y agoHow do you even end up in that situation? If you start a new feature or bugfix having random local changes lying around, you are _already_ doing it wrong. Start a feature branch, do clean commits of the current state, test, push, review, merge.
- pjc50 5y ago> if half of it has nothing to do with what’s intended. Perhaps the focus should then be on making it easier to get that junk out of the working tree? Better stashing?
- throw0101a 5y ago> It would be quite fun if we could have hierarchical commits, so I could add bits to a commit without having to squash/amend. Then you'd see the top-level work item as a "commit" and the individual changes as "subcommits". Would something like Mercurial's queues be something what you're looking for? * https://stevelosh.com/blog/2010/08/a-git-users-guide-to-mercurial-queues/ https://stevelosh.com/blog/2010/08/a-git-users-guide-to-merc... See especially "…with Two (or More) Patches" onwards.
- feanaro 5y ago> But that's what they've tested. https://pre-commit.com/ https://pre-commit.com/ helps with that. > It would be quite fun if we could have hierarchical commits, so I could add bits to a commit without having to squash/amend. Yes! I've been saying this for years. Branch merge commits are already this, kind of. However their UI sucks and there's an idea gap which prevents them from being fully understood as such "supercommits" composed of subcommits. For one, the user should be forced to give meaningful, high level commit messages for merge commits and the tooling should fold commits made on a merge branch into the merge commit by default (effectively linearizing the merged history).
- usrusr 5y agoThe history graph not presented as a list but as a collapsible tree, sounds good! Might need a change in merge commit message culture though, or more: in the workflows I have experienced, the best time for writing the message you'd see on the collapsed presentation would be branch time, not merge. Ideally you'd have a data model that keeps a "what is this" description for branches that can be updated as long as the branch lives and that gets moved to the commit message on merge. Could this be done with some combination of convention and hooks? I guess a file in the root that is always kept on target/into branch state, with the lost file content of the source/from branch moved to the commit message would be all that's needed?
- CRConrad 5y ago>> hierarchical commits, so I could add bits to a commit without having to squash/amend. > Branch merge commits are already this, kind of. However their UI sucks and there's an idea gap which prevents them from being fully understood as such "supercommits" composed of subcommits. Isn't that "idea gap" mainly the fault of all these weird newfangled git workflows that discourage or outright forbid branching? If you have no branches to merge, you can't have a merge commit to act as a "supercommit". Call your "supercommit" a "feature", and what you need to implement it is... A feature branch.