Monib Bormon
Monib Bormon

Reputation: 11

How can I remove last commit from git repository

I tried and also google it but never solve this problem. I found this command git reset --hard HEAD^ it also doesn't work.

Upvotes: 1

Views: 124

Answers (2)

Alex Akash
Alex Akash

Reputation: 1

Please use this command git reset --soft HEAD~1

Upvotes: 0

Houssem Ben Ali
Houssem Ben Ali

Reputation: 11

The git reset --hard HEAD^ instruction does not remove a commit by definition. It just forces the branch to point to the previous (parent) commit (^) on your local repository. To have the same status on the remote repository, you need to force push using git push <remote (default: origin)> <target_branch> --force. Be aware this push can erase others' works. You can use --force-with-lease instead of --force for more secure use.

Upvotes: 1

Related Questions