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.
If you want to move commits to an existing branch you need to merge your changes into the existing branch before executing git reset --hard HEAD~3 (see Moving to an existing branch above). If you don't merge your changes first, they will be lost.
You can cherry-pick a commit on one branch to create a copy of the commit with the same changes on another branch. If you commit changes to the wrong branch or want to make the same changes to another branch, you can cherry-pick the commit to apply the changes to another branch.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With