When you accidentally commit to master/staging and need to move the commit to a feature branch:
git branch new-branch-name # create a new branch from current one
git reset --hard HEAD~1 # remove last commit (change the number to remove more)
git checkout new-branch-name # checkout the new branch
Comments