[英]Local and remote branch has been diverged?
Here is my situation这是我的情况
For this, you cannot do a pull.为此,您不能进行拉动。 You did have the right idea though:不过,您确实有正确的想法:
git rebase main git rebase 主要
Then when locally everything is in order, force push ( git push --force
) to overwrite the remote "my branch", telling it that your state (which includes the commits added from main) is the correct one.然后,当本地一切正常时,强制推送( git push --force
)覆盖远程“我的分支”,告诉它您的状态(包括从 main 添加的提交)是正确的状态。
Lets say we have master, branch_A (made from master) and branch_B (also made from master).假设我们有 master、branch_A(由 master 制作)和 branch_B(也由 master 制作)。 I am working on branch_A and my friend is working on branch_B.我正在研究branch_A,而我的朋友正在研究branch_B。 My friends work in branch_B was merged to master.我在 branch_B 工作的朋友被合并到 master。 Now I am done and I want to merge my branch to master as well.现在我完成了,我也想将我的分支合并到 master。 The process I would follow is below:我将遵循的过程如下:
git checkout master
git pull
(update local master from with remote changes) git pull
(使用远程更改更新本地主机)git checkout branch_A
git rebase master
(this will pull in the changes from master and stack your branch commits on top) git rebase master
(这将从 master 中提取更改并将您的分支提交堆叠在顶部)git push origin branch_A -f
(need force since you rebased which changes branch HEAD) git push origin branch_A -f
(需要强制,因为你改变了分支 HEAD 的基础)Hope that helps.希望有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.