gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 14:43:38 27 4
gpt4 key购买 nike

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

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

最佳答案

转到您的 origin 存储库。添加带有 sandbox URL 的新 Remote 。然后将 sandbox/feature 分支 rebase 为 origin/master 分支。然后如果发生冲突解决它。

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

$ git rebase sandbox/feature

如果发生冲突,那么最好手动解决冲突。您还可以通过 --theirs--ours 标志接受 originsandbox 更改。

$ 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

关于git - 如何在两个git存储库之间 rebase ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42069876/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com