Skip to content

Instantly share code, notes, and snippets.

@mohokh67
Last active June 1, 2021 16:53
Show Gist options
  • Save mohokh67/1c2e2e94f7dba358cc5fed71456b23fa to your computer and use it in GitHub Desktop.
Save mohokh67/1c2e2e94f7dba358cc5fed71456b23fa to your computer and use it in GitHub Desktop.
Undo recent commits while keeping the changes

Find the commit hash you want to go back to by git log --oneline and then

git reset <commit_hash>

git reset without a --hard or --soft moves your HEAD to point to the specified commit, without changing any files.

Now you have the latest changes uncommited which you need to add and commit again.

If the commit was pushed, you can then do git push -f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment