[英]Git Merge Out of Sync Repos
I started using git to track my customizations to a 3rd party web app. 我开始使用git跟踪对第三方网络应用程序的自定义。 I interface with consultants that have been using git to track their changes for a while.
我与一直使用git跟踪其更改的顾问联系。 I'll try to make this easy to understand.
我将尽力使它易于理解。
Now from here all I want to do is go through and merge all the files that are different between [LOCAL] and [REMOTE] . 现在,我要做的就是浏览并合并[LOCAL]和[REMOTE]之间所有不同的文件。
I don't care about the branches or history I currently have in LOCAL. 我不在乎本地的分支机构或历史记录。 I only care about using REMOTE from now on and sending/receiving pull requests to interact with the consultants.
从现在开始,我只关心使用REMOTE以及发送/接收请求请求以与顾问进行交互。
How do you recommend I can do this? 您如何建议我可以做到这一点? I tried creating a new branch on LOCAL and overwriting all the files with the updated files from 3RDPARTY.
我尝试在LOCAL上创建一个新分支,并使用3RDPARTY中的更新文件覆盖所有文件。 Then I was hoping a merge between that new branch and my regular dev branch would give me a conflict so I could easily merge them all with KDiff3 but instead it just automerged and overwrote all my changes instead.
然后,我希望新分支与常规dev分支之间的合并会给我带来冲突,以便我可以轻松地将它们全部与KDiff3合并,但是它只是自动合并并覆盖了我的所有更改。
You tried to copy all the files over and just get a merge but it didn't work. 您试图将所有文件复制过来,只是合并了,但是没有用。 That should work, but I think you may need to follow some different steps which I'll try to explain.
那应该起作用,但是我认为您可能需要遵循一些不同的步骤,我将尝试解释这些步骤。
There should be a tag, or checking in 3RDPARTY
that was identical to a checkin point in your export environment which is the first checkin to LOCAL
. 应该有一个标签,或签入
3RDPARTY
,它与导出环境中的签入点相同,这是LOCAL
的第一个签入。 I will call this checkin MERGE_BASE
. 我将其称为
MERGE_BASE
。 So try these steps: 因此,请尝试以下步骤:
git checkout master
on REMOTE
and make sure it is up to date with 3RDPARTY
with git pull origin
. REMOTE
上执行git checkout master
,并确保它与git pull origin
3RDPARTY
是最新的。 REMOTE
git branch mergeb <MERGE_BASE>
<MERGE_BASE>
is the checkin I spoke about in the history that is identical, or as close as identical, to what you would have in your initial creation of LOCAL
. REMOTE
git branch mergeb <MERGE_BASE>
<MERGE_BASE>
是我在历史记录中谈到的签入,与您最初创建LOCAL
<MERGE_BASE>
相同或接近。 LOCAL
directly over top the files in your mergeb
branch we just created in REMOTE
. LOCAL
最新版本的源代码直接复制到我们刚刚在REMOTE
创建的mergeb
分支中的文件mergeb
。 DONOT copy the .git directory! REMOTE
on branch mergeb
use git add
to make sure all your changes are applied to the git index and then run git commit
. mergeb
REMOTE
上,使用git add
确保所有更改都应用于git索引,然后运行git commit
。 Now your REMOTE
mergeb
branch should have identical source to what is in LOCAL
. REMOTE
mergeb
分支应该具有与LOCAL
相同的源。 (you could use git remotes to do this with your LOCAL changes, but since you don't care about history I recommend just doing it this way to simplify the process). git checkout master
. git checkout master
分支git checkout master
。 git checkout -b remote_work
. git checkout -b remote_work
。 mergeb
branch into your remote_work
branch with git merge --no-ff mergeb
. mergeb
分支到您的remote_work
分支git merge --no-ff mergeb
。 At this point you will probably have all the conflicting merges with their work and your work to resolve. Once you finish this process and commit the work to your branch you should be now in the exact state you wanted. 完成此过程并将工作提交到分支机构后,您现在应该处于所需的确切状态。
After all of this, if you want all your work to appear as if you started with what is currently in 3RDPARTY
while on the remote_work
branch on REMOTE
simply do git rebase master
. 这一切后,如果您希望所有的工作出现,如果你开始与什么是目前在
3RDPARTY
而在remote_work
分支REMOTE
根本就git rebase master
。
From then on out I would keep master on REMOTE
synced with their 3RDPARTY
repo and keep your changes which hasn't been pulled into 3RDPARTY
in the remote_work
or other various branches on the REMOTE
repo. 从那时起,我将使
REMOTE
master与他们的3RDPARTY
库保持同步,并保留3RDPARTY
在remote_work
或REMOTE
repo上的其他分支中提取到3RDPARTY
中的remote_work
。
Let me know if this process works out for you. 让我知道这个过程是否适合您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.