3 ms·
This article contains some very dangerous advice. In particular it says that the difference between reset--hard and checkout is merely down to the working tree
by DenisM 4y ago
This article contains some very dangerous advice. In particular it says that the difference between reset--hard and checkout is merely down to the working tree changes not being preserved. What it does not mention is that reset will obliterate commit history subsequent to the requested revision 5f1bc85.
From the source:
Here’s me being straight up loco and resetting the head of my working tree to a particular commit:
$ git reset --hard 5f1bc85
The –hard option says to erase all changes currently in my working tree, whether they’ve been registered for a checkin or not (more will be said about this command later). A safer way to do the same thing is by using checkout:
$ git checkout 5f1bc85
The difference here is that changed files in my working tree are preserved.
- Oxidation 4y ago> reset will obliterate commit history subsequent to the requested revision 5f1bc85. It's not obliterated. It is still in the reflog, and in the history of any other branches or tags then have those commits in their history. You have to try quite hard or wait 2 months to obliterate something that was committed or stashed into a repo. You can even recover changes that were only staged. Compare this to most other programs (word processors, GIMP, etc) which will happily genuinely obliterate if you undo multiple times and then do anything other than immediately redo.