8 ms·
If you requested save in your favorite GUI application, text editor, etc and it popped open a select the changes you would like to save dialog, you wou
by taeric 9y ago
If you requested save in your favorite GUI application,
text editor, etc and it popped open a select the
changes you would like to save dialog, you would
rightly think just save all my changes already,
dammit
I'm sympathetic to what this is asking, but I have to feel that this would lead to much better practices for many people. I'd wager a ton of folks would be more "why in the world does it think I changed that?" than they would care to acknowledge.
That is, by and large, the quick sanity check of "these are the things you did?" is actually quite valuable. Regardless of any annoyance it may give. Similar to the "did you mean to print all 500 pages?" warning you can get if you print something huge. Sometimes, yes. Yes I did. Often times, no, not what I intended.
- jcranmer 9y agoIn my experience, the benefit you get is from giving you an editor to edit the commit message, which has a list of files changed, and can be cancelled in some way to abort the commit. Both hg and git can do this, so it's not necessary to have a separate command and staging area just to do it.
- icebraining 9y agoList of files is not enough, I always do 'git add -p' to see the actual changes. And sometimes I detect an error, and I want to fix it and then keep going without having to re-evaluate the changes I had already seen.
- MaxBarraclough 9y agoMy preference is for `git commit --verbose`, which shows all changes in a 'commented-out' section of the commit message file.
- ryanbrunner 9y agoThe authour of this article suggests a solution - `git commit --interactive` could prompt you for each change like `git add -p` does without needing a staging error. You're right though that it would take some cleverness in that command to allow you to fix a typo without restarting the operation.
- masklinn 9y ago> You're right though that it would take some cleverness in that command to allow you to fix a typo without restarting the operation. Would it though? Just finish your commit ("q" to skip the current hunk and every following one), then use commit --amend —interactive for the rest of the changes.
- jhasse 9y agoAlso you still haven't pushed the commit and could undo it.
- CSMastermind 9y agoOn source control anti-pattern I've run into is people thinking a commit is a 'save'. It's not. A commit should move you from one working state of your code to another. Compare that to saving my files which I do compulsively every 5 minutes or so regardless of the state the file is in.
- jononor 9y agoI agree, but... It is nice that one can compulsively (or automatically) save, with full history. And then when things are in a nice working state, be able to distill this into one or more clean changesets. `git rebase -i` makes this relatively easy/nice. I think even better tools for this would make it way more realistic to get away from the staging area as step in the default 'commit' process.
- Certhas 9y agoSo then why do I have the ability to stage individual lines of changes, creating commits that do not reflect a state that my system ever had, ergo was never tested or compiled in, thus can not be known to be working? Also, what if I use a remote to synchronize between different machines I work on on the same code base?
- flukus 9y agoI agree it's not a save, but a commit doesn't have to be in a working state either, at least on a private branch. A commit is a rollback point which may not even compile.
- eternalban 9y agoI parted company with the OP at that point. If he considers staging a "power user" feature then we're on two different planets.
- theptip 9y agoSounds like the OP would prefer the Gitless[1] porcelain; it removes the concept of staged files, and significantly simplifies the number of concepts required to work with Git. (This is a fun project because there's also a paper[2] that analyzes the design of Git from a conceptual level, and comes up with the simplifications that Gitless implements.) [1]: http://gitless.com/ http://gitless.com/ [2]: https://blog.acolyer.org/2016/10/24/whats-wrong-with-git-a-conceptual-design-analysis/ https://blog.acolyer.org/2016/10/24/whats-wrong-with-git-a-c...
- cryptonector 9y agoThere's three ways to deal with the git index/staging area: - always commit everything, merge/push that (Mercurial style) - always commit everything, then eventually do a rebase where you merge/split commits into logical units - always git add -e then commit logical units I do mostly the latter, but since I don't usually write code the way I want it in the end before pushing, I almost always have to go back and rebase to reorder, merge, and/or split commits prior to pushing. Like you, I'm sympathetic to the idea of "save everything", and I emphatically agree that it's fantastic that you get to save just the changes you want because it allows one to produce minimal and logical commits. I suspect that the author of TFA does not produce nice, clean, logical, and minimal commits. Instead I bet their upstream is full of merge commits and the merged branches are full of huge commits with lots of unrelated changes, and/or full of "fix a typo" commits that should never appear in upstream histories. Using a VCS effectively to create clean, useful history upstream is hard, and some VCSes make it harder than others. Mercurial (and Fossil, and...) make it supremely difficult. Git makes it easy (though one does have a bit of a learning curve to get there). Ironically, all the Merkle hash tree VCSes are git-like under the covers: there's a bag of commits, and some sort of branch name resolution. "Heavy-duty branches", like Mercurial's, are extremely confusing -- I never know how to recover from having multiple tips, and I don't even understand why that's at all possible. Whereas "light-weight" branching (like Mercurial's bookmarks, which still aren't reliable, or like git's branches, which are) is much much simpler -- even Mercurial's community gets this, though they still shy away from light-weight branches for some reason that I still don't understand. Fossil is exactly like git under the covers, except far, FAR superior to git in that it's relational -- Fossil is easily the best VCS ever in terms of implementation. But Fossil's dogma is highly opinionated and Mercurial-like: it has light-weight branches, but the UI is merge-happy like Mercurial's, and there's no rebasing (there's basic cherry-picking functionality, which of course is always the basis of rebasing, but that's it). I really don't want a Merkle hash tree VCS to hide its tree nature from me.
- fulafel 9y agoA goal of producing a "nice, clean, logical, and minimal" history, as opposed to preserving history, is very opinionated, as I'm sure you're aware. I think it's not something most people should attempt voluntarily - If you want "nice, clean" waypoints, just diff between the relevant merge commits, and read their commit messages.