NOTE: For the straightforward solution for the exact problem in the question look for the answers below, they are simpler.
For the more general problem of "I want to make some changes without messing up my working directory", keep reading.
See the comments about git worktree add
if your repo is very big.
Clone the repo, make rebase in cloned copy, and push it back.
If you are inside your repo, it should be:
cd ..
git clone <name_of_your_repo_directory> tmp_repo
cd tmp_repo
git checkout origin/oldBranch
git rebase origin/master
git push -f origin HEAD:oldBranch
In tmp_repo origin
is name of your local repo, of course (the one you cloned).
Note: the effect will be such as doing
git checkout oldBranch
git rebase master
in your original repo, not as
git checkout oldBranch
git rebase origin/master