[英]git pull from a github repository fork gives conflicts
I have forked rails git://github.com/rails/rails.git
at github. 我在github上分支了
git://github.com/rails/rails.git
。 My forked repository is at git://github.com/waseem/rails.git
. 我的分叉存储库位于
git://github.com/waseem/rails.git
。 I want to test out some patches submitted by other users to rails mainline. 我想测试其他用户提交到rails mainline的一些补丁。 Lets say I want to test out code in
migration_status
branch at git://github.com/joelmoss/rails.git
. 可以说我想在
git://github.com/joelmoss/rails.git
migration_status
分支中测试代码。
Lets say I 可以说我
master $ git remote add joelmoss git://github.com/joelmoss/rails.git
. master $ git remote add joelmoss git://github.com/joelmoss/rails.git
。 and 和
master $ git remote add mainline git://github.com/rails/rails.git
. master $ git remote add mainline git://github.com/rails/rails.git
。
I have been pulling from rails mainline into my master. 我一直在从Rails Mainline进入我的主人。
master $ git pull mainline master
According to http://guides.rubyonrails.org/contributing_to_ruby_on_rails.html#testing-patches I should create a local topic branch and pull in changes from joelmoss/migration_status
. 根据http://guides.rubyonrails.org/contributing_to_ruby_on_rails.html#testing-patches,我应该创建一个本地主题分支,并从
joelmoss/migration_status
中进行更改。 So I, 所以我,
master $ git checkout -b migration_status
Create a local topic branch. master $ git checkout -b migration_status
创建本地主题分支。
And when I do: 当我这样做时:
migration_status $ git pull joelmoss migration_status
I get a large number of conflicts. 我遇到很多冲突。 I also tried
migration_status $ git pull --rebase joelmoss migration_status
but I still get conflicts. 我也尝试了
migration_status $ git pull --rebase joelmoss migration_status
但是我仍然遇到冲突。
In the case of pull --rebase
, I think (correct if wrong), git is trying to apply my local changes on top of changes fetched from joelmoss/migration_status
. 在
pull --rebase
的情况下,我认为(如果正确,则正确),git尝试将我的本地更改应用于从joelmoss/migration_status
获取的更改joelmoss/migration_status
。 Ideally it should do the opposite. 理想情况下,它应该相反。 To consider this option, I did following.
为了考虑此选项,我做了以下工作。
master $ git fetch joelmoss
master $ git checkout -b joel_migration_status joelmoss/migration_status
and master $ git checkout -b joel_migration_status joelmoss/migration_status
和
joel_migration_status $ git rebase master
it still gave me lots of conflicts. joel_migration_status $ git rebase master
它仍然给了我很多冲突。
How do I pull in patches submitted to one of my local topic branches w/o getting conflicts? 如何提取提交到本地主题分支之一的补丁程序而不会产生冲突? I can not resolve those conflicts as I do not know much about what code to keep what not to.
我无法解决那些冲突,因为我对什么代码不知道该怎么做并不了解。
In this case, it looks like joelmoss/migration_status
is based off of 3.1.0, which split from mainline/master
back in May. 在这种情况下,
joelmoss/migration_status
看起来是基于3.1.0的,该版本从5月的mainline/master
分裂而来。 So if you merge you're trying to reconcile 4 months worth of development by everyone, in branches that appear to never have been intended to merge. 因此,如果您进行合并,那么您试图调和每个人4个月的开发价值,而这些分支似乎从未打算进行合并。
What you want to do is base your local changes on 3.1 as well. 您要做的是将本地更改也基于3.1。 That doesn't guarantee to remove all conflicts, but at least it should be ones you are aware of because it's code you changed directly.
那不能保证消除所有冲突,但是至少它应该是您所知道的,因为它是您直接更改的代码。
git checkout -b master-3-1 master
git rebase --onto joelmoss/migration_status mainline/master master-3-1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.