git fetch origin
git reset --hard origin/master
git commit -a -m "Saving my work, just in case"
git branch my-saved-work
git reset --soft HEAD~n
git commit -m "squashed n commit"
git push origin <your_branch_name> --force
but with new commit message with a concatenation of the existing commit message
git reset --soft HEAD~n &&
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
git checkout develop
git pull
git checkout -
git rebase develop
If file is already staged, to unstage the changes
Use
git reset HEAD <file>
Then
git checkout <file>
If not already staged, then:
git checkout <file>