I realized that I had to create a branch first, but already did 2 commits. Okay, I found this post Branch from a previous commit using Git and created a new branch from a prev-prev commit using this command:
git checkout -b branch-name commit-id
git push origin branch-name
But when I looked back in GitHub I saw the master still has 2 last commits (that I wanted them to be only in a branch).
What should I do to get rid of them in the master but still keep them in the branch?
UPD Found this solution.
- Reverted to the previous commit
git reset --hard commit
- Pushed with force git push
--force origin master