Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nuna's avatar
Level 1

Is that possible to revert back to specific commit in git?

I accidently merge wrongly using vs code into master branch which is used for deployment and I should rewind the branch back to 3 commits earlier. Is there a way to do this? Please help.

0 likes
2 replies
martinbean's avatar
Level 80

@nuna git reset --hard HEAD~3

This will delete those last three commits though.

If you’re having merge conflicts then I’d suggest learning about rebasing, as it sounds like you need to rebase your feature branches against your main branch before merging back into your main branch.

Please or to participate in this conversation.