相关疑难解决方法(0)

在Git中重新定位远程分支

我正在使用一个中间Git存储库镜像远程SVN存储库,人们可以从中进行克隆和处理.中间存储库的主分支从上游SVN每晚重新定位,我们正在开发功能分支.例如:

remote:
  master

local:
  master
  feature
Run Code Online (Sandbox Code Playgroud)

我可以成功地将我的功能分支推回到远程,并最终达到我的期望:

remote:
  master
  feature

local:
  master
  feature
Run Code Online (Sandbox Code Playgroud)

然后我重新设置分支以跟踪远程:

remote:
  master
  feature

local:
  master
  feature -> origin/feature
Run Code Online (Sandbox Code Playgroud)

一切都很好.我想从这里做的是将功能分支重新绑定到远程主分支,但我想从我的本地机器上执行此操作.我希望能够做到:

git checkout master
git pull
git checkout feature
git rebase master
git push origin feature
Run Code Online (Sandbox Code Playgroud)

使远程主控分支与远程主服务器保持同步.但是,这种方法导致Git抱怨:

To <remote>
 ! [rejected]        feature -> feature (non-fast-forward)
error: failed to push some refs to '<remote>'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' …
Run Code Online (Sandbox Code Playgroud)

git version-control branch rebase feature-branch

127
推荐指数
3
解决办法
12万
查看次数

标签 统计

branch ×1

feature-branch ×1

git ×1

rebase ×1

version-control ×1