git move 在本地提交对新分支的更改并推送
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17429091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git move locally committed changes to the new branch and push
提问by Quillion
I am on master
. When I do git status I am told
我在master
。当我执行 git status 我被告知
$ 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
所以所有 13 个只存在于我的本地机器上。问题是这 13 次提交现在应该在我应该创建并推送到服务器的新分支上进行。我曾尝试查看 rebase,但有人告诉我
$ 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?
我将如何将这些更改推送到一个新的分支中而不会弄乱 master?
Just to clarify. This is not a duplicate of
moving committed (but not pushed) changes to a new branchthis one simply does not work for me no matter what I do.
or
Git: Howto move changes since last commit to a new branchagain is of no help.
只是为了澄清。这不是
将已提交(但未推送)的更改移动到新分支的副本,无论我做什么,这对我都不起作用。
或
Git:如何将自上次提交以来的更改再次移动到新分支没有帮助。
回答by Balog Pal
Just do git checkout -b yourbranch
and push that.
做git checkout -b yourbranch
并推动它。
Then reset master to origin/master.
然后将 master 重置为 origin/master。
Order:
命令:
git checkout -b mybranch
git push
git checkout master
git reset --hard origin/master