(branch) a - b - c - d - e - f - g
/ /
(master) 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 ...
git rebase --onto c d g
git checkout -b newbranch
(newbranch) e' - f' - g'
/
(branch) a - b - c - d - e - f - g
/ /
(master) 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 ...
If you are happy with the results, then throw away the old branch and rename the new branch:
git branch -D branch
git branch -m newbranch branch
Finally push the new branch.
git push -n origin branch # check what you're about to push
git push -f origin branch # -f is required to rewrite history; be careful