There are different schools of thought when it comes to manipulating the development history. One might be that every commit is retained and nothing is altered (realistic history). One might be a fine-grained realistic history where you commit every change ASAP. Didactic realistic history might be to take your time and commit your best work only at convenient and suitable moments.
There can be a lot of value in the full, fine-grained realistic history. It can provide archaeological details that provide insight into the introduction of a bug or how the developers work and how the process can be improved. But a cleaner history with well-defined steps can be a joy to read and a pleasure to work with.
There can be a lot of value in the full, fine-grained realistic history. It can provide archaeological details that provide insight into the introduction of a bug or how the developers work and how the process can be improved. But a cleaner history with well-defined steps can be a joy to read and a pleasure to work with.
Caution About Altering History
As a general guideline, you should feel free to alter commits in a branch as long as no other developer has a copy of the branch.
Using git reset
The git reset command changes your repository and working directory to a known state. git reset adjusts the HEAD ref to a given commit and updates the index to match that commit. git reset can also modify the working directory to mirror the revision of your project represented by the given commit.
It has three main options: --soft, --mixed, and --hard.

Article notes
What does this command do?
git reset --soft commit
Changes the HEAD ref to point to commit
What does this command do?
git reset --hard commit
Changes the HEAD ref to point to commit, changes the contents of the index to match with the commit's tree structure, and changes the working directory to reflect the same tree structure