在Linux上有没有一种方式可以挂载一个Git分支(只读)?

3

安装:在工作中,我们有一个git仓库来存放我们的脚本。这些脚本需要在我们所有的客户端Linux机器上(约400个)都可以访问。目前的解决方案是有一个文件服务器,定期拉取主分支,然后挂载(nfs+autofs)。

问题:有没有一种简单的方法来只读挂载远程git分支?

我知道GitFS,但这似乎过于复杂了。我正在寻找一些轻量级的东西,最好是内存中,即不需要在磁盘上检查内容。我只需要访问一个分支,不需要历史记录。

编辑:为了澄清:我想避免拉取和cronjobs等等。最好是一些透明地挂载远程git仓库的方式,就像只读nfs挂载一样。

1个回答

0
问题:有没有一种简单的方法可以将一个远程 git 分支只读挂载?
是的,你可以用几种方法来实现。 bundlearchive 都是只读存储库。 git bundle
# Clone the desired branch (-b flag)
# and pack it into a bundle with the desired name
git clone repo.bundle repo-copy -b master

这个的输出是一个单一文件,其中包含所需的分支以只读模式显示,因为它不是 git 存储库。


git archive

类似于上面的bundle命令

# Create a tar archive that contains the contents of the latest commit 
# on the current branch, and 
#extract it in the /var/tmp/junk directory.
git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)

@codeWizerd,你的回答中没有挂载远程仓库。或者我漏看了什么? - Tristan Storch

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接