Files
30-seconds-of-code/snippets/rewind-to-commit.md
2022-03-22 12:02:38 +02:00

725 B

title, tags, expertise, author, firstSeen, lastUpdated
title tags expertise author firstSeen lastUpdated
Rewind back to a specific commit branch,commit intermediate maciv 2021-04-05T11:19:21+03:00 2021-04-13T21:10:59+03:00

Rewinds the current branch by a given number of commits.

  • Use git reset <commit> to rewind the current branch to the specified <commit>.
  • This command will uncommit and unstage changes, but leave them in the working directory.
  • You can use the --hard flag to uncommit, unstage and delete changes instead.
git reset [--hard] <commit>
git reset 3050fc0d3
# Rewinds back to `3050fc0d3` but keeps changes in the working directory

git reset --hard c0d30f305
# Rewinds back to `c0d30f305` and deletes changes