Rolling back changes in [[Git]] can be done when changes are committed that break the code, and it consists of choosing a previous commit or state and ignoring all changes after that point.
Warning: rolling back is a destructive process. All changes after the point selected will be lost. To prevent accidental data loss, clone the repo first (or copy it into another folder).
## Get the SHA ID of a commit
To identify the commit you want to roll back to, use [[Fork (app)]] to right click on the commit and copy the SHA ID.
### Reset to a commit
Then, use this command: `git reset <SHA> --hard`
Without the `--hard` flag, you might get an error. This flag ignores that and proceeds in deleting all later commits.
### Usage
I had to do this on [[2021-01-11]] when I accidentally merged my branch with itself, duplicating commits.