Revert git repo to previous commit

I have a problem with git. I develop my local host, push the changes to my repo, and then pull to my site. I recently created a page on my localhost that worked just fine. Then I clicked on my repo and pulled it to the site. For some reason, the changes violated my site. For example, there are hashes of broken commit and working commit:

ABCDE 'This commit works on the local host and in real time on the site
ZYXWV 'This commit works on the local host, but not in real time.

So, I made commit ZYXWV on my localhost and transferred it to the repo. Then I pulled ZYXWV into my live site, which broke it. To fix my site, I did the following:

git check ABCDE

So now my site is working. The only problem is that my live site does not sync with my repo, which means that I canโ€™t change anything without getting broken code. I donโ€™t need a broken code, and everything is fine if it is deleted. I just need a way to restore the repo with ABCDE again.

Hope that made sense. I'm not so good with git. Thank you for your help.

+4
source share
1 answer

It looks like you can do it

git revert ZYXWV 

This will create a new commit that will return a commit that does not work on the real site. Now you can pull this to the site and make a git checkout master .

Then you can continue and try to recreate a better commit than ZYXWV, which will work everywhere.

+4
source

Source: https://habr.com/ru/post/1479033/


All Articles