As a developer the situation when you accidentally commit unwanted codes or credentials or codes that should not be there happens quite often, especially when you’re the project lead.
This can be implemented easily if your source code is managed by Git.
The steps to achieve this are:
- Reset back to your desired commits. In this example, I’ve moved back 1 commit
git reset --hard HEAD~1
- Push your changes to match the remote repository.
git push --force