12 ms·
The fact that even simple commands require googling, time and time again, because they violate the principle of least surprise (https://en.wikipedia.org/wiki/Pr
by 7373737373 3y ago
The fact that even simple commands require googling, time and time again, because they violate the principle of least surprise (https://en.wikipedia.org/wiki/Principle_of_least_astonishment https://en.wikipedia.org/wiki/Principle_of_least_astonishmen...) is just sad.
Like, the question: "How do I undo 'git add'" shouldn't have over ELEVEN THOUSAND upvotes on StackOverflow: https://stackoverflow.com/questions/348170/how-do-i-undo-git-add-before-commit https://stackoverflow.com/questions/348170/how-do-i-undo-git...
That's just bullshit
- kazinator 3y agoIf you let git know about some file that was previously not indexed, and then do a "git reset --hard", that file is gone. (You can find it if you dig through the git object store with some obscure commands.)
- deleted 3y ago[deleted]
- jer0me 3y agoWait how does 1/3 + 25 equal 5.333?
- p1mrx 3y agohttps://archive.org/details/studyofprogrammi0000stan/page/122/mode/2up?q=astonishment https://archive.org/details/studyofprogrammi0000stan/page/12... "Consider the expression 1/3 + 25. In PL/I this expression has the value 5.33333333333. Why? One-third is computed to 15 digits of precision, 14 to the right of the decimal point. Then 25 is coerced to the same precision, losing the most significant digit 2! This does raise an error in PL/I, but the default is to ignore it."
- jer0me 3y agoWow, that is a lot of surprise.
- hparadiz 3y agoI completely agree. Some commands are not intuitive at all. I always wanted git stage [file], git unstage [file] instead of add and reset. I totally understand why those were chosen when the original code for git was written but I really think it's time to re-evaluate the CLI and do better.
- vjk800 3y agoThis would make a lot of sense actually. It would also remove the confusion new people often have over what does it mean for changes to be staged
- kazinator 3y agoGit's documentation should somehow prominently teach people that: - Git stores snapshots, not changes. - Snapshots go into something called an index. "Git add" means to add to an index. - A new commit is prepared by creating a new index based on the index of the HEAD commit. This new index is the "stage". The index holds a complete copy of the files. When you stage only certain changes with "git add --patch", that is still the case: you're making a version of the file which has only those selected changes and that goes into the index. A built-in tool that is external to the git representation did the text manipulation to separate those changes. - When you commit, the uncommitted index you have created as a stage becomes a commit.
- sshine 3y agoThat's a good explanation. I've copied it to a colleague who is learning.
- adhesive_wombat 3y agoI think the Git maintainers realise that and introduce commands like "restore", even though the action can be (and was for a long time) achieved with the original command set. Also I believe "git stage" exists too: https://git-scm.com/docs/git-stage https://git-scm.com/docs/git-stage Because git commands are used in a bajillion scripts, it's very hard to remove "excessive" functionality from the old commands even when that would improve the orthogonality of the tools.
- Trigg3r 3y agoYeah, "undo the last thing I did" - There is no button / single command (as far as I know) - you google and get loads of "if this, do this, else this" - dang, I just want to undo and get on with what I need to do!
- morelisp 3y agoIf the last thing you did was switch branches do you want to undo switching branches, or undo the last thing you did on the branch? If the last thing you did was stage, do you want to unstage, or undo the last change outside the staging area? If undoing the last thing you did is not compatible with the current state of the working copy, what happens? If your last change was to discard or apply uncommitted changes, how can that be undone? If the answer is "do lots of hidden commits", how does that interact with undo?
- Trigg3r 3y agoVisual Studio, for example, switch, stage - it makes the option obvious (bring changes, or discard?), got no problems there, un-doing something that I have committed - that is what I am mentioning, no easy to undo... (is it local stage? do this, did you push? do this..., have other people in repo got the changes, do this, etc...), got shiz I need to be doing rather than reading these details ;)
- 112233 3y agothese all are excellent questions the undo tool could ask user.
- godelski 3y agoI think the number of upvotes is because the time (since 2008). But also git tells you how to undo this if you run `git status`.
- cosmotic 3y agoUndo is one of many fundamental usability shortcomings of all (commonly used) CLIs. Also includes feedback, consistency, system status, discoverability, actionable error messages, etc.