I did a commit 2 days ago by mistake in git remote repository that make a lot of errors in live website.
How can I get back to previous version before 2 days ago but in remote repository not in my local test code only?
EDIT
I do git checkout master
CodePudding user response:
- git reset --hard #reset local changes
- git clean -fd #remove untracked files and folders
- git fetch #fetch latest
- git checkout master #switch to master
- git pull #get latest from master
- git checkout -b my-fix-branch #create new branch from master
- git revert {faulty-commit-hash} #remove your change
- git push -u origin my-fix-branch:my-fix-branch #push to remote
- git checkout master #switch again to master
- git merge my-fix-branch #merge fix to master
- git push #push to master
Notes:
- If you get merge conflicts on step 7 you will need to fix them.
- If you don't have rights to modify master directly, after step 8 create a pull request from "my-fix-branch" to "master"