Help needed to revert back to a previous github commit

Hi all

I’ve needed to go back to a previous state with all my files and have done that but now can’t push that previous state. It just gives this warning:

My repo looks like this:

I want to lose the top two commits and have the one with the tick as my latest.

Can anyone come to my rescue? I’m still a git novice!

Download GitHub desktop app — it doesn’t have the limitations and bugs of the internal git manager.

1 Like

Ooh, I didn’t know Github had their own app. I have Sourcetree but have always just used the built-in git features in Wappler.

I’m the only person using the repo. The link you mentioned talks about fetching from the remote. Does it mean pulling? That, presumably, will pull those two newer commits back down again which I don’t want to do.

So maybe you are using on multiple computers in this case and you’ve already changed the remote repo?

Yes, I switch between desktop and laptop. What’s the method for getting both to the right position?

You push the changes to remote from computer 1. Then you pull the changes from remote on computer 2 and do what is explained in the topic i linked to.

OK. This is my situation.

Desktop (where I’m currently working):

Laptop:

What do I need to do to get both back to this:

On Desktop, open terminal in Wappler and do a force push: git push -f.
This will remove the higher commits in remote and bring it back to the commit you want.

On laptop, switch to another branch, then remove master from local, and then checkout master again.
If you don’t have another branch, create one just for this purpose, then delete after switching to master.
If you do not wish to create a branch, delete the project folder from your machine and do a fresh clone.

Thanks @sid. I did try that but it doesn’t like me using password authentication:

remote: Support for password authentication was removed on August 13, 2021.

I think I should set up SSH keys.

Hi again @sid. I was thinking I was using username/password but I now realise I used oauth from my browser to give Wappler access. Terminal in Wappler isn’t letting me do the forced push, though (see above).

Do you know what I should do to be able to do it?

I have never had a problem with running commands on terminal.
You can try the same thing on source tree. They have a Git terminal option.
Maybe you need to authenticate this Git repo via browser access or personal access token instead of username password that you might have used.

Generally, the access given from Wappler is enough for system Git to get access… But it could that you are using some other option in the Git installation. Windows/Mac could be a cause of issue as well.

Thanks @sid. I realised I was using the oauth browser authentication so would have thought it would all work fine. I’ll try again.

I’ve managed to sort it by deleting my repo at Github, recreating it and then pushing my local one to it. Really simple solution that just works. Perhaps not as tidy as being able to do it with the existing repo but not a big deal.

Posting this in case someone else is in a similar position.