Introduction
I have a problem. Well, I have several, but this one is that I keep pushing changes into my main branches instead of creating a feature branch. I don’t usually do this, I am fairly disciplined, but whenever I am on calls with people and I am distracted, I frequently make a tiny change on the screen to show people what needs to be done and then later i check it in on that branch.
This leaves my main branch with changes that I don’t want.
The Answer
To fix the situation, assuming I don’t want the code I checked in, I need to reset the main branch back to that on the server. This is a simple git command: –
git reset --hard origin/main
‘main’ should be replaced with whatever root, develop, main branchin name you use.
This will lose the changes in the checkins you did – so, if you need them, copy those changes out to another branch before you do this.