git reset --soft HEAD~1

Reset the current branch and move the HEAD pointer to the previous commit, keeping the changes staged.

This command undoes the last commit by moving the HEAD pointer to the previous commit while preserving the changes from the undone commit in the staging area. This allows you to make further changes and create a new commit without losing the work done in the undone commit.

The --soft flag specifies the reset mode as soft, which means that the changes from the undone commit are kept in the staging area. Alternatively, you can use the --mixed flag (default) to unstage the changes and place them in the working directory, or the --hard flag to discard the changes entirely.

The HEAD~1 argument specifies the commit to reset to, which in this case is the previous commit. You can modify the number to specify a different number of commits to go back.

Here's an example of another variant:

git reset --soft <commit>: Reset the current branch to the specified , keeping the changes staged.

Sign in to enable bookmarking, reminders, progress-tracking and more...

Sign in to enable bookmarking, reminders, progress-tracking and more...

Sign in to enable bookmarking, reminders, progress-tracking and more...