After having used SVN for over 5 years it is hard getting used to the Git work flow. Once in a while code is committed to the master branch that should have been committed to a feature branch.
Create feature branch
The first thing to do is create the branch that contains the feature you were working on and push it to origin:
git branch <feature-branch> git push origin <feature-branch>
Temporarily set the remote HEAD to something else than master, otherwise you will not be able to delete it.
git remote set-head origin <feature-branch>
The next step is to delete your master branch on your remote repository. If you use Atlassian Stash you should first set the default branch to some other branch. This can be configured under Repository>Settings>Repository Details.
Reset your local and remote master branch
Now delete your master branch on your remote repository:
git push <remote> :master
The next step is to reset your local master to the point you wish to reset to, the point before you started working on the feature you’d like to branch out.
git reset --hard <commit-hash>
The master in your local repository should be pointing to the correct changeset. Now push this new master branch to your remote repository.
git push <remote> master
Now you can set the remote HEAD back to the master branch.
git remote set-head origin master
The last step if you use Atlassian Stash is to set the default branch to master again.