As is common with powerful tools there is more than one way of doing the same thing.
cd your-website
git switch main
git branch nonworkingchanges
git reset --hard hashoflastworkingversion
git push origin --force
- Go to your website folder
- Switch to the main branch, if you are not there already.
- Create a new branch “nonworkingchanges”, a copy of the main branch.
- Reset the main branch to the hash of the last change that worked on your site.
- Push the changes to the original repository. Using “force” to disable checks that normally not allow you to push changes that will lose commits
The “switch” command was introduced in git last year to take over some function from the overloaded “checkout” command.