Difference between git reset: soft vs hard

1 min read

To be able to partially apply commits to other branches some times comes handy to use git reset together with git stash.

With git reset we will be able to modify how the changes are stored on the repository. Let's see the differences between git reset --soft and git reset --hard.

When what we want is to delete a specific commit without loosing it's changes (usually to apply them later on using git stash) we will have to use the --soft flag

git reset --soft

It will leave all your changed files as "Changes to be committed"

On the other hand, it we want to reset the index and the working tree, discarding any changes to tracked files in the working tree and trowing away all your uncommitted changes; then we will want to use the --hard flag:

git reset --hard

Posted on 19/05/2021