2

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
  • 389,931
  • 88
  • 552
  • 692

2 Answers2

4

Create a new branch:

git checkout -b myNewBranch

Push to repo:

git push
Alex Pan
  • 4,135
  • 7
  • 31
  • 44
3

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,228
  • 2
  • 21
  • 22