Question

I have a git problem. I develop on my local host, push changes to my repo, then pull to my live site. I recently built a page on my localhost, which worked fine. Then I pushed to my repo and pulled to the live site. For some reason the changes broke my live site. For example purposes, here are the hashes of the broken commit and the working commit:

ABCDE 'This commit works on the local host and the live site'
ZYXWV 'This commit works on local host but not live site'

So I made the commit ZYXWV on my local host and pushed it to the repo. Then I pulled ZYXWV to my live site, which broke it. In order to fix my live site I did the following:

git checkout ABCDE

So, now my live site is working. The only problem is that my live site is not in sync with my repo, which means I can't pull any changes without getting the broken code. I don't need the broken code and am okay if it gets deleted. I just need a way to get the repo in sync with ABCDE again.

I hope that made sense. I am not that great with git. Thanks for your help.

Was it helpful?

Solution

It sounds like you may want to do this

git revert ZYXWV

This will create a new commit reverting the commit that is not working on the live site. Now you can pull this to the live site and do git checkout master.

Then you could proceed and try to recreate a better commit than ZYXWV that will work everywhere.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top