我的n
存储库中包含我想在服务器目录中提供的内容。将动态扫描服务器目录中的内容以用于该内容。
但是,我想保留我想导入的存储库。我不想合并或执行任何单向任务。源存储库实际上应该保持独立。
当我git pull
在服务器目录上时,我想更新所有我订阅的文件。请注意,它不一定必须是,git pull
但您可以理解我的意思。
这就是它的样子(有更多的文件和存储库,这只是一个示例):
- github
- repo 1 with 10 files
- repo 2 with 5 files
- server
- content-directory
- 2 files "subscribed" out of repo 1
- 1 file "subscribed" out of repo 2
我在其中进行github
的操作后,应立即将仓库上的更改应用于服务器目录文件git pull
。
有没有简单的方法可以做到这一点?
我的方法:在其中创建这些存储库的克隆,content-directory
但是尽管我只需要一些文件,但我将获得整个存储库。.gitignore
阻止上传但不阻止下载。
也许已经有一种我不知道的好方法。
据我所知,尚无本机Git功能,但是您可以使用符号链接获得所需的结果,符号链接在POSIX系统上可用,在具有NTFS的Windows上也可用。
我将在这里假设一个Linux系统。
将您的存储库检出到内容目录之外的某个位置:
$ cd /some/directory/repos
$ git checkout https://github.com/user/repo-a.git
$ git checkout https://github.com/user/repo-b.git
$ ls
repo-a/ repo-b/
现在,将每个存储库中所需的文件链接到服务器的内容目录中:
$ cd /path/to/server/content/directory
$ ln -s /some/directory/repos/repo-a/file1 .
$ ln -s /some/directory/repos/repo-a/file2 .
$ ln -s /some/directory/repos/repo-b/file1 file1b
这些文件显示在目录中,但是如果使用长列表(-l
),则可以看到它们实际上是指向其他文件的链接:
$ ls
file1 file1b file2
$ ls -l
file1 -> /some/directory/repos/repo-a/file1
file1b -> /some/directory/repos/repo-b/file1
file2 -> /some/directory/repos/repo-a/file2
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句