简体   繁体   English

使用git合并项目的两个版本

[英]Merging two versions of a project with git

Consider the following scenario. 请考虑以下情形。 There're two git repos, representing two versions of project P. Repo A has P v0.1 with some custom patches and repo B has P v0.2 without these patches. 有两个git仓库,代表项目P的两个版本。仓库A具有带有一些自定义补丁的P v0.1,仓库B具有没有这些补丁的P v0.2。 How to merge patches from A into repo B, using git? 如何使用git将补丁从A合并到仓库B中? Or is it better to just manually check which files were modified and "import" patches by manually diffing all changed files? 还是仅通过手动比较所有已更改的文件来手动检查修改过的文件并“导入”补丁会更好?

The beautiful thing in git is that a repo is a just repo, so you can pull a repo A branch from repo B just as if you did it from a remote git的美丽之处在于,一个仓库就是一个公正的仓库,因此您可以从仓库B中拉出仓库A分支,就像从远程仓库中取出仓库一样

git remote add repoA /path/to/repoA/.git
git pull repoA

That's assuming they are on same filesystem. 假设它们在同一文件系统上。 If they aren't you need to use some protocol. 如果不是,则需要使用一些协议。 Probably easiest way is to 可能最简单的方法是

repoA
--------
git daemon --base-path=path/to/one/dir/above/repoA --export-all

repoB
--------
git remote add repoA git://<repoA_IP>/repoA
git pull repoA

repoA
--------
shutdown daemon(Ctrl+C)

You need to enable traffic on port 9418. Unfortunately you may get various errors running it under windows, but at least some are fixable - you need to consult google for details. 您需要在端口9418上启用流量。不幸的是,您可能会在Windows下运行该错误,但至少有一些可修复的-您需要向谷歌查询详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM