gpt4 book ai didi

linux - 有没有办法在 Linux 上挂载一个 git 分支(只读)?

转载 作者:太空狗 更新时间:2023-10-29 12:28:11 25 4
gpt4 key购买 nike

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

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

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

编辑: 澄清这一点:我想避免 pull 和 cronjobs 之类的东西。最好的是透明地挂载远程 git 存储库的东西,就像只读的 nfs 挂载一样。

最佳答案

Question: Is there an easy way to mount a remote git branch read only?

是的,您可以通过多种方式做到这一点。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 存档

类似于上面的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 -)

关于linux - 有没有办法在 Linux 上挂载一个 git 分支(只读)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35600001/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com