4

I have local commits on the master branch, but (due to unforeseen external reasons) I now can't push my changes to master and instead need to push them to a new remote branch (that can be merged back to master later).

How do I (safely) do that?

Bohemian
  • 412,405
  • 93
  • 575
  • 722

2 Answers2

4

Create a new branch:

git checkout -b myNewBranch

Push to repo:

git push
Alex Pan
  • 4,341
  • 8
  • 34
  • 45
4

The easiest way, without creating a new local branch as mentioned in the answer before, would be: Imagine you are on branch test localy and want to push it to a new branch called test-remote

$ git push origin test:test-remote

ckruczek
  • 2,361
  • 2
  • 20
  • 23