Move the commit to a new branch:
The following commands will create a new branch called ‘feature’, then hard resets staging and working tree the existing branches HEAD to the previous commit.
git branch feature
git reset --hard HEAD~1 #or commit SHA1
Move the commit to an existing branch:
Merge new commits in first and then follow the steps given below:
git checkout existingbranch
git merge master
git checkout master
git reset --hard HEAD~2 #Go back 2 commits, Note that You will lose uncommitted work.
git checkout existingbranch
For more commands like this please go through the following tutorial that will help you understand the git