7

If I simply do "checkout some_commit" it will switch me to this commit. But what I need is to stay on the current branch (master to be specific) and totally replace all files in it with files from some_commit. How can I do that?

1 Answer 1

15

git reset --hard <commit>

(I'm sure this is a duplicate, but don't have time to search.)

2
  • Be sure to do this after making current the branch you want to replace
    – Dan Piponi
    Commented Jun 5, 2021 at 22:22
  • How to create a new commit when this happens? Like StackExchange edits, "Rollback to sha"
    – minseong
    Commented Apr 5, 2022 at 23:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.