The main workflow for a developer will follow these steps
A commit is like a snapshot of the Git repository at one point in time. Adding commits keep track of our progress and changes as we work. Git considers each commit change point or "save point". It is a point in the project you can go back.
You should make new commits often, based around logical units of change.
When we commit, we should always include a message.
By adding clear messages to each commit, it is easy for yourself (and others) to see what has changed and when.
This short Snipp shows you how to remove the last commit from the git repository.
1. Check the logs
First of all, check your local commit with messages before removing the last commit. Run the following command to check the logs in one line.
git log --oneline
2. Remove the last commit from the local branch
Now, Run the following command to remove the last commit and discard the changes from the local branch.
git reset --hard HEAD~1
Checkout the different ways to Undo commit before push in Git.
3. Update remote repository
At last, we will update the files and again need to push with force. It will delete the previous commit and keep a new one on the remote git repository.
git push origin <name_of_branch> -f
Now you can check the logs to verify the commit in the git repository.