How to soft reset in Git
Soft reset in Git undoes commits while preserving all changes in the staging area, allowing you to recommit with better organization, improved commit messages, or different file groupings. As the creator of CoreUI, a widely used open-source UI library, I’ve used git reset –soft countless times across development workflows to reorganize commits, improve commit messages, and prepare cleaner history before sharing with the team. From my expertise, the most effective approach is using git reset –soft to move the branch pointer back while keeping all changes ready for immediate recommitting. This method provides safe commit reorganization with preserved work and flexible recommitting options.
Use git reset –soft to undo commits while keeping all changes staged and ready for new commits.
# Soft reset to previous commit
git reset --soft HEAD~1
# Soft reset to specific commit
git reset --soft abc1234
# Soft reset multiple commits
git reset --soft HEAD~3
# Check status after soft reset
git status
# Shows all changes from undone commits as staged
# Recommit with new message
git commit -m "Improved feature implementation"
# Split changes into multiple commits
git reset --soft HEAD~2
# Now you can selectively commit files
git commit -m "Add user authentication"
git add remaining-files.js
git commit -m "Add user profile management"
# Soft reset to merge commits into one
git reset --soft HEAD~4
git commit -m "Complete user management feature
- Add authentication system
- Implement user profiles
- Add password reset functionality
- Include user preferences"
# Verify what will be reset before doing it
git log --oneline -5
git diff --cached # After reset, shows staged changes
Git reset –soft moves the branch pointer backward while leaving the index (staging area) and working directory unchanged. All changes from the undone commits remain staged and ready for new commits. This is perfect for reorganizing commit history, improving commit messages, or combining multiple commits into fewer, more logical commits.
Best Practice Note:
This is the same soft reset workflow we use in CoreUI development to create clean, logical commit history before pushing features to shared repositories.