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

LiBinbinOriginalLess than 1 minute


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>


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
  • Latest
  • Oldest
  • Hottest