3 ms·
Anyone who thinks they can mansplain git to me should read first understand my StackOverflow answer, where I give detailed instructions on how to "git stash" on
by kazinator 4y ago
Anyone who thinks they can mansplain git to me should read first understand my StackOverflow answer, where I give detailed instructions on how to "git stash" only the staged changes, in a git that doesn't have the recent --staged option in git stash. This is done by manipulating raw tree objects to create commits in the way stash wants them.
https://stackoverflow.com/questions/14759748/how-can-i-stash-only-staged-changes-in-git/72582276#72582276 https://stackoverflow.com/questions/14759748/how-can-i-stash...
I've been using this thing daily since around 2008.
I think the behavior that is described by my post is suprising and poor. A command which throws away uncommitted changes removed a file whose only connection to the version control system was that its existence was announced to it. (I don't require to be informed about the mechanics of how that came about, due to what procedures being applied to what representations, all of which I understand.)
People writing version control systems should take some kind of oath against anything like that happening.
Under no circumstances lose any file that is not completely in version control, without confirmation.
- evgpbfhnr 4y agoI can try anyway: your file is still accessible with this (file content is 'foo\n') $ git cat-file --batch-all-objects --batch 257cc5642cb1a054f08cc83f2d943e56fd3ebe99 blob 4 foo But as others said, yes I'd expect this. You wanted reset (soft). (EDIT: formatting)
- Freak_NL 4y ago> Anyone who thinks they can mansplain git to me […] How is dswilkerson's gender relevant here? (Or yours, given that mansplaining typically implies a man needlessly explaining something to a woman.) I don't think they've even stated that irrelevant signifier anywhere on HN.
- sgammon 4y ago“under no circumstances without confirmation” but you did that when you passed it —hard…
- alkonaut 4y agoYes —hard should lose files without confirmation Yes you made a commit by initializing (your HEAD points to the state of the repo that has zero files and reset —-hard to that state means “make my repo have that empty state and don’t ask me to confirm whatever is changed or deletes in order to get there”). Git has lots of sharp edges and surprising things but this is completely unsurprising to me. I think your misunderstanding here is around what “reset —hard” does. I think with a mental model including the root (empty) state of the repo it’s easier to understand.