Git子模块与Repos中的回购 [英] Git Submodules vs repos inside repos

查看:89
本文介绍了Git子模块与Repos中的回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的网站回购,我会打电话给mysite。然后我有一个叫做myApp的小型django应用程序。我认为myApp很有用,所以我希望其他人能够下载它并将其作为子模块包含在他们的应用程序中。但我想保留在mysite里面的回购。



目前我有一个mysit的git repo,里面有我的另一个git repo for myapp。我似乎可以将 cd 放入其各自的目录中,并推送/拉出/编辑更改。但是,我没有做任何事情来将其中一个设置为另一个的子模块。那是我需要做的事吗?或者是,只有当我在mysite中使用某人elses模块并且不会对模块进行更改时? 解决方案

如果你想将你的嵌套回购交换到一个子回购模块,你所需要的就是:


  • 将你的嵌套回购商品移动到父回购商之外

  • 类型:


    $ b $

      git子模块add / remote / url / of /嵌套/回购




使用 / remote / url / of / nested / repo 是你从嵌套的repo推送到源时使用的url。
完成:

  git子模块更新--init 



<然后添加新的 gitlink条目,该条目刚刚在索引中创建,提交并推送(从父回购)



任何克隆mysite的人都可以执行混帐子模块更新--init ,并会发现你的嵌套回购作为子模块,在gitlink记录的最后一个版本检出。



它意味着你的父母回购'mysite'不再包含所有嵌套回购(这将需要一些空间),但只通过gitlink(索引中非常小的条目)引用所述嵌套回购。


I have a repo for my site I will call mysite. I then have a small django app I made called myApp. I think that myApp is kind of useful so I want other people to be able to download it and include it as a submodule in their apps. But I want to keep the repo inside mysite.

Currently I have a git repo for mysite and inside that I just have another git repo for myapp. I seem to be able to cd into their respective directories and push/pull/edit changes just fine. However, I haven't done anything to set one up as a submodule of the other. Is that something that I need to do? Or is that only if I am using somebody elses module inside mysite and am not going to be making changes to the module?

解决方案

If you want to switch your nested repo to a submodule repo, all you need to to is:

  • move your nested repo outside the parent repo
  • type:

    git submodule add /remote/url/of/nested/repo
    

With /remote/url/of/nested/repo being the url used when you were pushing to origin from your nested repo.
Complete with:

git submodule update --init

Then add the new gitlink entry which has just been created in the index, commit and push (from the parent repo)

Anyone cloning mysite will be able to do a git submodule update --init and will find your nested repo as submodule, checked out at the last version recorded by the gitlink.

It means your parent repo 'mysite' doesn't include anymore the all nested repo (which would takes some space), but only references said nested repo through a gitlink (very small entry in the index).

这篇关于Git子模块与Repos中的回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆