20

I am on master. When I do git status I am told

$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 13 commits.
#   (use "git push" to publish your local commits)
#
nothing to commit, working directory clean

So all 13 only exist on my local machine. The problem is that these 13 commits are now supposed to go on a new branch that I should create and push onto the server. I have tried looking at rebase but I am told

$ git rebase origina/master
fatal: Needed a single revision
invalid upstream origina/master

How would I go about pushing these changes into a new branch without messing up the master?

Just to clarify. This is not a duplicate of
moving committed (but not pushed) changes to a new branch this one simply does not work for me no matter what I do.
or
Git: Howto move changes since last commit to a new branch again is of no help.

4

1 回答 1

55

Just do git checkout -b yourbranch and push that.

Then reset master to origin/master.

Order:

git checkout -b mybranch
git push
git checkout master
git reset --hard origin/master
于 2013-07-02T15:05:56.080 回答