作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
设置: 在工作中,我们有一个 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?
是的,您可以通过多种方式做到这一点。bundle
和archive
都是只读
存储库。
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/
我是一名优秀的程序员,十分优秀!