Push to a different remote branch | The Git Push Command
When working with Git, it can sometimes happen that you finished a task (committing and pushing your final work) but forget to switch to a new branch for your next task. You stay on the same branch without noticing and start working. Finally, you commit your changes and want to push them. At that point you realize that you committed your changes on the wrong branch.
Luckily, that’s not a problem when working with Git. You can leave everything as it is and specify where to push to by using the following command:
git push origin source_branch:target_branch
The above command means "push the changes from local source_branch to origin target_branch".
Let’s say you were working on branch taskOne and stayed there after finishing your first task. Afterwards you should have switched to a new branch, taskTwo, but forgot to do so. You did the implementation for task two on branch taskOne and committed there. What you can do now to push to the remote branch taskTwo is the following:
git push origin taskOne:taskTwo
This command will push your changes made on local branch taskOne to origin taskTwo branch.
For full reference see Git push documentation.