如何用git管理多个相似但不同的项目?
我有多个基于相似代码库的不同闭源项目,每天我都需要将更改和修复从一个项目复制到另一个项目,然后再复制回来。
由于我的一些项目差异太大,无法使用 git 子模块,而在其他项目中,我不希望我的客户弄乱子模块,从而窥视我在其他项目上的工作,现在我使用 git patch 来做到这一点, git apply
这是一项乏味的工作。
我打算考虑在我的机器上的本地存储库之间切换到 git pull 和 git push ,从而使用 gitcherry-pick 和 。 git merge 来获取所需的更改,但是否有更好的方法?
I have multiple different closed source projects based on a similar code base and every single day I need to copy changes and fixes from one to another and back.
As some of my projects are diverged too much to use git submodules and in others I don't want my clients mess with submodules and consequently peek into my work on other projects now I do that with git patch
and git apply
which is a tedious job.
I am about to consider a switch to git pull
and git push
between local repositories on my machine consequently using git cherry-pick
and git merge
to pick up needed changes, but if there is a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下更像是建议
子树合并
将存储库拼接在一起
我对此也很感兴趣,如果我得到任何明确的答案,我将提供更新。
The following are more like suggestions
Subtree merging
Stitching together repositories
I'm really interested also in this and I'll come with an update if I get to any definitive answer.
使用
gitcherry-pick
可以做你想做的事。通过将其他存储库作为可以从中获取的远程存储库,您仍然可以挑选单个提交。您也不必创建远程分支,只需获取更改并挑选您想要移植的提交的 sha1 即可。当您推送时,它不应该推送其他获取的引用,因为它们不在您当前的分支上,而只是精选的提交。Using
git cherry-pick
may do what you want. By having the other repository as a remote you can fetch from, you can still cherry-pick single commits. You don't have to create a branch of the remote either, just fetch in the changes and cherry-pick the sha1 of the commit you're wanting to port. When you push, it shouldn't push the other fetched references, as they're not on your current branch, just the cherry-picked commit is.