git > discard local changes (no return!) with reset — hard
1 min readAug 6, 2020
The concern is documenting removing all the changes done in the working area of the git repo. Beware: this is about resetting uncommitted changes, there no return — you just burn it for good. So be sure you know what you’re doing.
1. condition: no commit no reset
- you can reset changes to what has been committed
- so you can reset modification or removal
- if you, however, add/create a new file and do not commit it,
git reset --hard
does logically nothing with it - the same for branches -> you cannot reset the creation of a branch
2. use-cases
- clone/pull → mess up a file → immediately want to return to the state of the pull
- clone/pull/commit → delete a file by mistake in a working area → restore it right away
3. command
git reset --hard
Originally published at github