Revert a git branch state to a previous commit


How to revert state of a git branch to a previous commit from an older state

Posted on To reset index to former commit, where ‘26e05ffab‘ is the code associated with the old commit:

git reset 26e05ffab

Move pointer back to previous HEAD:

git reset --soft HEAD@{1}

Make a local commit of the whole revert:

git commit -m "Revert to commit 26e05ffab"

Update working copy to reflect the new commit

git reset--hard

Push the changes to remote branch:

git push origin [branch_name]

Push the changes to remote master branch:

git push origin [branch_name]:master

Categories TechTechTutorialsTags Leave a comment