You have made some commits, pushed it upstream to the remote branch, then realized that some or all of those commits must for some reason not be included. In example, accidently commiting large multimedia files (blobs) that will forever bloat the commit history of the branch.
- ensure all changes are commited in your current, "faulty" branch
- switch to your master branch
git checkout master
- update master with latest changes on remote
git pull origin master
- create a new branch and check in to it
git checkout -b <new-branch-name-squash>
- ensure you're in the new branch
git branch
- merge changes from "faulty" old branch into this new branch
git merge <old-faulty-branch> --squash
- this will merge all the changes from the old branch into the new one while ignoring the commit history
- do a status update to see what's cooking
git status
- you may now re-stash/add, starting with a clean slate