Skip to content

Instantly share code, notes, and snippets.

@4sskick
Last active August 18, 2025 06:34
Show Gist options
  • Save 4sskick/7de05ee677a4c5853c744fda476225ef to your computer and use it in GitHub Desktop.
Save 4sskick/7de05ee677a4c5853c744fda476225ef to your computer and use it in GitHub Desktop.

This gonna be a solution for you whenever you wanna rollback commit HEAD on repo GIT to specific point commit reflog just because you wrongly push some code and don't wanna make it dirty on repo. Or your client doesn't pay you after you've work. You can use this method. This method gonna delete histories commit after you revert / rollback to specific point of commit. Or you can say this is a HARD RESET

  • get the log historis of commit you've already pushed on repo with command git reflog
  • something like 155b09b HEAD{3}: commit message here gonna shown, on most left side you gonna see code commit
  • choose one to where you wanna revert histories
  • use this command, git reset --hard <commit-id>
  • then type git push -f <origin or others> <branch master or others>
  • done and see yourself
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment