简体   繁体   English

使用目录作为外部的 Git 存储库

[英]Git repository using directory as externals

I have an SVN repository with some documents using the same reference (bibtex) files via svn:externals.我有一个 SVN 存储库,其中包含一些通过 svn:externals 使用相同参考 (bibtex) 文件的文档。 Its contents looks like this:它的内容是这样的:

bibtex/
doc1/
-doc1.tex
-bibtex/ (svn:externals)
doc2/
-doc2.tex
-bibtex/ (svn:externals)

This way I could checkout each paper individually and obtaining the same reference.这样我就可以单独检查每篇论文并获得相同的参考。 How can I setup the same with git?如何使用 git 设置相同的内容?

I read that submodules were suggested, but if I try (after git svn clone)我读到建议使用子模块,但是如果我尝试(在 git svn clone 之后)

git submodule add ./bibtex ./doc1/bibtex

I obtain我得到

fatal: repository '/home/user/repo/bibtex' does not exist
Clone of '/home/user/repo/bibtex' into submodule path 'doc1/bibtex' failed

You need to make sure bibtex is in its own Git repository.您需要确保bibtex位于其自己的 Git 存储库中。 Which is not how svn external is used, since it is a "relative external" link to a folder of the same repository.这不是svn external的使用方式,因为它是指向同一存储库文件夹的“相对外部”链接。

Plus, after a git svn clone , you could reorganize your Git repo only if you do not intent to git svn dcommit back to the SVN repository.另外,在git svn clone ,只有当您不打算将git svn dcommit返回到 SVN 存储库时,您才可以重新组织您的 Git 存储库。

If that is the case, then yes, you could:如果是这种情况,那么是的,您可以:

That is:那是:

cd /path/to/svl-cloned/repo
cd doc1
git rm -r bibtex/
git commit -m "remove bibtex"
git submodule add /url/remote/bibtex/repo bibtex
git add .
git commit -m "Add bibtex submodule"

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

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