git reset/revert to previous commit
Sometimes we "accidentally" merge something that's not ready for release/qa  and need to rollback/ 2021-12-2 08:57:0 Author: blog.gtiwari333.com(查看原文) 阅读量:18 收藏

Sometimes we "accidentally" merge something that's not ready for release/qa  and need to rollback/reset/revert the commits to a cleaner state.

Here's how you can safely reset your git to previous commit:

1) find the older commit id to where you want to reset.

2) do git status to confirm there are no uncommitted changes on the current branch  

3) reset to a commit,

git reset --hard COMMIT_ID
git reset HEAD@{1}
git add .
git commit -m "reverting to commit COMMIT_ID"

4) cherry pick or patch any other commit that you like to add



文章来源: http://blog.gtiwari333.com/2021/12/git-resetrevert-to-previous-commit.html
如有侵权请联系:admin#unsafe.sh