如何在多个项目之间共享.git文件夹?
我想使用 Git 存储库或子存储库就像 Mercurial Share 扩展中的那样。
所以,这就是我所拥有的:
mkdir orig
cd orig
echo "osthuaosteh" > abc
git init --shared
git add abc
git commit -m 'init'
cd ..
mkdir another
如何在 another
中初始化一个存储库,以便它与 orig
共享存储库?
我需要这个作为一个大库,我想将其包含为子存储库。该存储库重达数百兆,因此我想重用一些文件夹。
更新:我希望能够在不同的工作文件夹中有不同的修订版本。
I want to work with Git repositories or sub-repositories like in Mercurial Share extension.
So, here's what I have:
mkdir orig
cd orig
echo "osthuaosteh" > abc
git init --shared
git add abc
git commit -m 'init'
cd ..
mkdir another
How can I initialize a repo in another
so that it shares the repository with orig
?
I need this for a big library that I want to include as a sub-repository. The repo weighs hundreds of megs, so I want to reuse some of the folders.
Update: I want to be able to have different revisions in different working folders.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想问你的是:你真的需要共享存储库吗?
与 Mercurial 一样,当您进行本地克隆时,git 会在存储库之间创建硬链接,从而只消耗很少的额外磁盘空间。例如:
repo-copy1
和repo-copy2
存储库中的大多数文件将硬链接到repo
,并且不会消耗额外的磁盘空间。只有工作副本中的文件才是实际副本。您可以这样确认此行为:
如您所见,克隆 65880 块存储库(每个块 512 字节)后,文件系统上的块计数仅减少了 664 块。
如果您从远程服务器克隆(子)存储库,您可能必须手动创建到其他本地克隆的硬链接;对于 Mercurial,您可以使用
relink
扩展; git 等效项似乎也被称为。What I would ask you is: do you really need to share the repository?
Like Mercurial, git creates hard-links between repositories when you make a local clone, resulting in only little extra disk space consumption. E.g.:
Most files in the
repo-copy1
andrepo-copy2
repositories will hard-link torepo
, and will not consume extra disk space. Only the files in the working copy are actual copies.You can confirm this behaviour like this:
As you can see, after cloning a 65880-block repository (of 512 bytes each), the block count on the file system went down by only 664 blocks.
If you clone a (sub)repository from a remote server you may have to manually create the hard links to other local clones; for Mercurial you would use the
relink
extension for that; the git equivalent also seems to be called that.对于 git-submodules ,这将在路径
another
: 中(以及您的示例)。您尝试过 git submodule --help 吗?
With git-submodules that would be (and with your example) in path
another
:. Have you tried
git submodule --help
?