简体   繁体   English

我可以从git中的多个存储库中自动将代码拉到新存储库中吗?

[英]Can i auto pull code to a new repo from multiple repos in git?

I need to club multiple git repos to one single repo, in an attempt to club the scattered code. 我需要将多个git存储库合并到一个存储库中,以尝试合并分散的代码。

At this step I am not re factoring any code just clubbing all related projects from 4 different repos(say repoA, repoB, repoC and repoD) to one single repo(say repoFinal). 在这一步中,我不会分解任何代码,而只是将所有相关项目从4个不同的回购(例如repoA,repoB,repoC和repoD)合并到一个单一的回购(例如repoFinal)中。

However my concern is that, new commits and pushes will be made to repoA, repoB, repoC and repoD almost everyday.How do I keep up with the changes in all four repo and update that in my repoFinal on daily basis? 但是我担心的是,几乎每天都会对repoA,repoB,repoC和repoD进行新的提交和推送,如何跟上所有四个repo的更改并在每天的repoFinal中进行更新?

Is there any way I can automate this? 有什么办法可以使它自动化? or do I need to keep a track of it manually? 还是我需要手动跟踪它?

I did read about web hooks, however I am not sure 我确实阅读过有关Web挂钩的信息,但是我不确定

1) if it will work if I have 4 repos to be updated in one repo? 1)如果我有4个存储库要在一个存储库中更新,是否可以工作?

2) structure of repoFinal will be different than all other four repos eg: 2)repoFinal的结构将与所有其他四个repos不同,例如:

repoA --> ProjectA repoA-> ProjectA

repoB --> ProjectB repoB-> ProjectB

repoC --> ProjectC, ProjectG repoC-> ProjectC,ProjectG

repoD -->ProjectD, ProjectE and ProjectF repoD-> ProjectD,ProjectE和ProjectF

finalRepo --> ProjectA, ProjectB,ProjectG, ProjectD, ProjectE (I do not want ProjectC and ProjectF in my new repo) finalRepo-> ProjectA,ProjectB,ProjectG,ProjectD,ProjectE(我不希望在新的仓库中使用ProjectC和ProjectF)

Any suggestions or insight will be helpful. 任何建议或见解都会有所帮助。

Create a FinalRepo and add the other repos using git submodules. 创建一个FinalRepo并使用git子模块添加其他仓库。 Each time you want to synchronize you just go in to each submodule and do a git pull and then commit the FinalRepo at the root. 每次要同步时,只需进入每个子模块并执行git pull,然后在根目录下提交FinalRepo。

Have a look at https://git-scm.com/book/en/v2/Git-Tools-Submodules 看看https://git-scm.com/book/en/v2/Git-Tools-Submodules

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

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