You have to have the branch checked out to pull, since pulling means merging into master, and you need a work tree to merge in.
git checkout master
git pull
No need to check out first; rebase does the right thing with two arguments
git rebase master test
git checkout master
git merge test
git push by default pushes all branches that exist here and on the remote
git push
git checkout test