如何在两个git存储库之间进行rebase

时间:2017-02-06 14:14:23

标签: git

我们有两个远程存储库用于相同的项目源和sandbox。现在我在原始主分支并尝试拉沙箱功能分支但我遇到了冲突问题。

那么我应该如何在origin master分支上重新设置我的沙箱功能分支? 这是一个常规的事情,那么在这种情况下解决冲突的最佳做法是什么? 注意:我已经检查了类似的问题 How to rebase one Git repository onto another one? How to rebase one repo to another

1 个答案:

答案 0 :(得分:3)

转到您的origin回购。使用sandbox网址添加新的远程。然后将sandbox/feature分支到origin/master分支。然后,如果发生冲突,请解决它。

# go into your origin repo
$ git checkout master
$ git remote add sandbox <sanbox-repo-url>
$ git fetch sandbox

$ git rebase sandbox/feature

如果发生冲突,则可以手动更好地解决冲突。您还可以originsandbox标记接受--theirs--ours更改。

$ git status        # see the conflicted files (red color)

# resolve conflicts
$ git checkout --theirs <file-name>    # accept origin changes
Or,
$ git checkout --ours <file-name>      # accept sandbox changes   
相关问题