1) create a new branch based on the current one (to store everything, just in case). git checkout -b new-branch existing-branch
if you want to work on this new branch, stay here.
if you want to work on the old one,
git checkout old-branch-name
git push origin my_new_branch to reflect the changes online (i double check on github.com just to be sure.)
git log to count the number of reverts (or get the id). scroll with arrow bars, press q to quit.
git reset --hard HEAD~x where x is the number of commits to roll back to. THIS DELETES ALL THE COMMITS AFTER THAT so please make sure you have already kept another branch with all your other commits if necessary (step 1). update: it is good practice to reference via the commit id rather than the number of commits, eg
git reset --hard c14809fa just to be sure. i learnt the hard way when i somehow managed to roll back, squash all my commits into ONE commit, then i rolled by again by 10 commits, hence bringing me NINE commits earlier than i wanted to. moral of the story, just use the id instead of hard coding in the counts.
5) IF you get an error saying you are behind the head by x number of commits and they ask you to git pull, AND you are sure that it is the local copy of your git branch you want to keep, use this:
git pull origin branch-name -s ours where s is for strategy, and the strategy is to use ‘ours’ aka the local copy. otherwise it will bring you up to date with the master again (which i didn’t want).
also apparently there are faster ways to do this but somehow i managed to screw them up lol
much thanks to:
and of course my personal git advisor :p