CoreUI ONE — 250+ PRO components and 25+ admin templates for React, Angular, Vue, Bootstrap and Next.js, plus Data Grid, Scheduler, 4,300+ PRO icons and the Next.js boilerplate. One license. → See what you get

How to reset a commit in Git

Resetting commits is crucial for cleaning up local repository history before sharing changes, allowing you to reorganize commits and remove unwanted changes. As the creator of CoreUI, a widely used open-source UI library, I’ve used git reset extensively for local history cleanup. From my expertise, the most versatile approach is using git reset with different modes depending on whether you want to preserve or discard changes. This provides precise control over how commits are undone and what happens to the affected files.

Use git reset with different modes to control how commits are undone.

git reset --soft HEAD~1
git reset --mixed HEAD~1
git reset --hard HEAD~1

Here --soft moves HEAD back one commit but keeps changes staged, --mixed (default) unstages changes but keeps them in working directory, and --hard completely discards all changes. The HEAD~1 syntax refers to the commit before the current HEAD. Choose the mode based on whether you want to preserve the changes for recommitting.

Best Practice Note:

This is the same reset strategy we use in CoreUI development for local commit cleanup before pushing. Never use git reset on commits that have been pushed to shared repositories, as it rewrites history and can cause conflicts for other developers.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
Genius Bootstrap Admin Template
Genius Bootstrap Admin Template

Accessible Focus Traps: Trap the Keyboard, Not the User
Accessible Focus Traps: Trap the Keyboard, Not the User

CoreUI v6 Alpha vs Bootstrap 6 Alpha: What We Took, What We Didn't, and Why
CoreUI v6 Alpha vs Bootstrap 6 Alpha: What We Took, What We Didn't, and Why

CoreUI v6 Alpha: What Changes and Why
CoreUI v6 Alpha: What Changes and Why