git pull # Get latest changesgit reset --soft HEAD~4 # Set back 4 stepsgit stash # Stash the resetgit pull # Go back to headgit stash pop # Pop the resetgit commit -m "Revert" # Commit the changes
git reset --soft HEAD~(number of commits you'd like to revert)git commit -m "The stuff you didn't like."git log# copy the hash of your last commitgit revert <hash of your last (squashed) commit>
# checkout the branch that should be targetedgit checkout $branch_target
# revert the commits in $branch_target to some $count where# $count is the number of commits to revert# cut is used to slice just the commit hash field from each line of output# xargs runs the command once for each line of input, reversing the commits!git log --oneline -n $count | cut -d' ' -f1 | xargs git revert
# check out the branch which should be the source of the pull requestgit checkout -b $branch_for_pull
# revert the revert commits# $count is that same number of commits being reverted (again)git log --oneline -n $count | cut -d' ' -f1 | xargs git revert
# push branches up and go off to create PR in whatever web UIgit push --set-upstream origin $branch_for_pull # it's new!git checkout $branch_targetgit push # if this branch wasn't pushed, just fix the issue locally instead..