简体   繁体   中英

git move locally committed changes to the new branch and push

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM