Cancel Last Commit When Already push

Photo by Markus Spiske on Unsplash

This how I cancel last commit when it already push on gitlab, there a couple solution but this work for me , and follow this step for fixing. go to git history you can check in your github/gitlab etc.

There are several other ways but this is the way I’ve tried and it works. this in stackoverflow use “git revert” and check this link

First Step

Reset to <commit id> what you want to be last commit example:
[feature] commit what you want to remove 3x311x8x
[feature] commit must be the last bx3x2x8x

$ git reset — hard <commit-id>

$ git reset --hard b3ee42c8
HEAD is now at b3ee42c8 [last]

Second Step

clean your local drive in project, explanation of this code
(-f) force
(-d) drive

$ git clean -f -d

Third Step

Check status your git , response must be like this:
“nothing to commit, working tree clean”

$ git status

Fourth Step

add + (plus) before your branch
$ git push -u origin +<branch-name>

$ git push -u origin +feature/parent



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store