Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git将本地提交的更改移动到新分支并推送_Git_Branch_Git Branch_Rebase_Git Rebase - Fatal编程技术网

git将本地提交的更改移动到新分支并推送

git将本地提交的更改移动到新分支并推送,git,branch,git-branch,rebase,git-rebase,Git,Branch,Git Branch,Rebase,Git Rebase,我在主机上。当我做git状态时,我被告知 $ 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 $ git rebase origina/master fatal: Needed a

我在
主机上
。当我做git状态时,我被告知

$ 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
$ git rebase origina/master
fatal: Needed a single revision
invalid upstream origina/master
所以所有13个都只存在于我的本地机器上。问题是这13个提交现在应该在我应该创建并推送到服务器上的新分支上进行。我试过看瑞贝斯,但有人告诉我

$ 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
$ git rebase origina/master
fatal: Needed a single revision
invalid upstream origina/master
我如何将这些更改推进到一个新的分支中而不破坏主分支

我只是想澄清一下。这不是
不管我做什么,这个对我根本不起作用。


同样没有帮助。

只需执行git checkout-b yourbranch并推动它即可

然后将主机重置为原点/主机

订单:

git checkout -b mybranch
git push
git checkout master
git reset --hard origin/master

请重新表述问题,解释为什么最后一个链接不是您问题的解决方案,因为它肯定是针对您所述的链接。@BalogPal因为它只涉及一个更改,而不是13个更改,因此我认为它会有所不同。如果不是,那么我将很乐意这样做,道歉并关闭/删除此问题。我应该试试吗?这些变化是2个月的工作,我不能失去它。在问题中,你说“这13项承诺现在应该结束了”。如果你真的只想要一个或两个,你应该要求;如果您有您的承诺,那么在git中很难丢失任何东西。但是,由于它允许许多方式和方法,你应该精确地询问。可能如果您描述了结果状态,我们会是ahead是的,我想提交所有13个更改,但是链接只提供了一个最新更改的解决方案。我不知道有什么不同,最后一个链接和下面的答案的结果是什么,你会在原点上看到,主分支不变,13次提交出现在一个新的分支上,从您的origin/master现在指向的commit开始:1)git checkout-b mybranch2)git push3)git reset-hard origin/master就是这样吗?在3)git checkout master之前警告:这个序列对我不起作用。与其将“13”个新本地提交移动到一个新分支,保持远程完整,至少我只想在新分支上进行的一些最新更改会出现在master(或者在我的例子中是developer)中。我不认为这是OP的本意。@BryanP我想可能是git push不仅推送签出的分支,而且其他()步骤2)可能需要是
git push origin mybranch