This web page requires JavaScript to be enabled.

JavaScript is an object-oriented computer programming language commonly used to create interactive effects within web browsers.

How to enable JavaScript?

Reset a commit on the remote repository server with git reset

Blog May 12, 2022 0

Imaging that we commit and push the wrong code and we want to reset completely. So we can use git reset with --hard and then push back to the remote repository with git push

Case study

We want to reset commit add deployed on IIS to the previous commit Update sdk + lib + packages

Step 1: Copy the SHA of the commit before the wrong commit. This case, the wrong commit is add deployed on IIS and we will reset the branch to the previous commit Update sdk + lib + packages with SHA 1027e32f9393b568e2e11e5bbf062f598fe7ba1b.

git reset 1027e32f9393b568e2e11e5bbf062f598fe7ba1b --hard

Step 2: Push back to the remote repository:

git push origin -f

Now, the lastest commit will be Update sdk + lib + packages

Next post will show how to recover a reset/deleted commit, read here:

Personal experiment
Nam Le.

Last modified on May 26th, 2022 at 3:24 pm

Nam Le

0 responds

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.