Skip to main content

Git withdraws the commit that has been submitted to the remote repository

AndyBinOriginalLess than 1 minute

Caption

When we are working, we often encounter that the remote repository has been submitted, but it is not the version I want and needs to be withdrawn. The following commands can then be used:

# Do not delete workspace modifications, only revoke commits
git reset --soft <commit_id>

# Delete workspace modifications, undo commits
git reset --hard <commit_id>

Tips

git reset --soft means that only the point of HEAD is changed, the local code will not change, we can still see it using git status, and can also submit with git commit.

git reset --hardThe latter directly changes the local source code, not only points to the change, but also the code returns to the code of that version, so use it with care and think clearly.

Last update:
Contributors: rumosky
Comments
  • Latest
  • Oldest
  • Hottest