[Info] How to delete/revert commit from Git

 

First, checkout the branch where you need to work on:

git checkout myBranch

To see all the commits:

First, checkout the branch where you need to work on:

git log --pretty=oneline --abbrev-commit --full-history

If you need to revert just the last commit, you can do:

git reset --hard HEAD~

Or you can revert to a specific commit, like this:

git reset --hard c1e3c7d

Now you need to push the changes:

git push origin +myBranch

 

Sources:

https://ncona.com/2011/07/how-to-delete-a-commit-in-git-local-and-remote/

http://stackoverflow.com/questions/35979611/how-to-delete-latest-git-commit-in-bitbucket

 

Attached Files
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Name
Email
Security Code Security Code
Related Articles RSS Feed
[How To] Rename a local and remote branch in git
Viewed 1515 times since Mon, Mar 6, 2017
MENU