5 ms·
With git reset --hard protection do you mean accidentally resetting a branch which has uncommitted changes? If you do that a lot, why not commit your changes m
by jnurmine 8y ago
With git reset --hard protection do you mean accidentally resetting a branch which has uncommitted changes?
If you do that a lot, why not commit your changes more often to your topic branch? You can always squash it later to make it look nice.
Or use stash or something.
- chx 8y agogit reset --hard throws away work. Nuclear bomb operations should never be a simple switch away.
- jnurmine 8y agoOf course it does. So does rm -rf. The dd command can ruin your entire disk with a typo.
- chx 8y agoTheir primary goal, however, is not tracking changes. Of course a tool made for deleting or lower level copying is destroying data, that's their primary use. git, however, is almost always undoable.
- jnurmine 8y agoIf you have not committed the changes, then Git is simply not aware that you want to keep those changes in the first place. It is like editing a file, and not saving it. Is the editor at fault? Should it autosave the file? Under what name? Under what directory? Or should the editor just do what you tell it to? For this particular case, git stash might help. In general (danger: personal opinion), it is good practise to be mindful of dangerous commands and take a deep breath before issuing them, whatever they are. That is what I do after having learnt it the hard way, as I have also messed up stuff with the hard Git reset, dd, rm, chmod, chown, cp, mv, tar, you name it... So, if you ask me, Git does not have an "objectively bad UI" as some say, it just does what it is told to. (Insert joke about computers being like an Old Testament God.)
- chx 8y agoRead Jef Raskin's Humane Interface. > It is like editing a file, and not saving it. Is the editor at fault? Yes > Should it autosave the file? Yes > Under what name? Under what directory? I don't care, just stash it somewhere so my work doesn't get lost. Notepad++ does it, for example. It doesn't even reveal where does it stash it, but "Noname 1" happily survives even a reboot.