gerrit配置及使用git-lfs

gerrit服务器端配置

下载git-lfs插件

  1. 登录Dashboard [Jenkins] (gerritforge.com),下载对应版本的插件

配置gerrit

  1. 将下载的lfs.jar插件放到${GERRIT_SITE}/plugins/下面

  2. 为所有仓库启用git-lfs

    1. 此步骤需要修改 All-projects 仓库配置,步骤如下 1、克隆仓库,检出到refs/meta/config

      |---------|---------------------------------------------------------------------------------------------------------------------------------------------------|
      | 1 2 3 4 | git clone ``"ssh://admin@192.168.60.148:29418/All-Projects" cd All-Projects git fetch origin refs``/meta/config git checkout FETCH_HEAD |

    2. 添加LFS配置文件``lfs.config``,写入如下内容

      |-------|------------------------------------------------------------------------------------------------|
      | 1 2 3 | [lfs ``"^.*"``] ``enabled = ``true # 启用LFS ``maxObjectSize = 500m ``# LFS允许的最大对象 MiB |

    3. 提交到 All-projects 仓库并合入变更

      |-------|------------------------------------------------------------------------------------------|
      | 1 2 3 | git add . git commit -m ``"add lfs config" git push origin HEAD:refs``/meta/config |

  3. 在gerrit.config中启用lfs,在gerrit.config中增加如下内容

    |-----|---------------------------|
    | 1 2 | [lfs] ``plugin = lfs |

复制代码
      指定存储类型,在${GERRIT_SITE}/etc下增加lfs.config,写入以下内容(如不填写directory的值则默认会将lfs文件的数据保存在$GERRIT_SITE/data/lfs)

  |-----|-------------------------------|
  | 1 2 | `[storage]` ` ``backend = fs` |
  1. 重启gerrit

    |---|--------------------------------------------|
    | 1 | ${GERRIT_SITE}``/bin/gerrit``.sh restart |

客户端配置

  1. 安装git-lfs软件包(执行用户需要有sudo权限)

    |-----|------------------------------------------------------------------------|
    | 1 2 | sudo apt ``install -y git-lfs # 安装成功后可执行git lfs version查看安装的版本 |

客户端使用

  1. 在Git仓库中为仓库设置相关配置

    |---|---------------------|
    | 1 | git lfs ``install |

    Tips:

    这个命令会自动改变Git配置文件 .gitconfig,而且是全局性质的,只需要配置一次,会自动在配置文件中增加如下配置:

    filter "lfs"

    clean = git-lfs clean -- %f

    smudge = git-lfs smudge -- %f

    process = git-lfs filter-process

    required = true

  2. 选择要用LFS追踪的文件

    |---------|---------------------------------------------------------------------------------------------------|
    | 1 2 3 4 | git lfs track ``"*.svg" # 或者具体到某个文件 git lfs track ``"2.png" git lfs track ``"example.lfs" |

    Tips:

    这个命令会更改仓库中的 .gitattributes配置文件(如果之前不存在这个文件,则会自动新建):

    查看如下:

    $ cat .gitattributes

    *.svg filter=lfs diff=lfs merge=lfs -text

    2.png filter=lfs diff=lfs merge=lfs -text

    example.lfs filter=lfs diff=lfs merge=lfs -text

  3. 查看lfs追踪文件

    |---------|---------------------------------------------------------------------------------------------|
    | 1 2 3 4 | git lfs ``ls``-files 9a3c7dae41 * example.lfs d61cf5835a * 2.png 158213f90f * 3.svg |

  4. 保存并提交配置

    |---------|--------------------------------------------------------------------------|
    | 1 2 3 4 | # 提交 git add . git commit -m ``"add Large File Storage" git push |

    注意:

    如git仓库中配置了使用lfs来管理大文件,则在repo sync之后执行以下命令拉取大文件

|---|-----------------------------------|
| 1 | repo forall -c ``'git lfs pull' |

相关推荐
悠然大月季1 小时前
git 怎么导出提交历史,文件是乱码
git·git导出历史记录·git导出历史乱码
chenshiming8023 小时前
在cursor下执行GIT回退版本
git
打点计时器6 小时前
Git快速上手教程
git
1104.北光c°7 小时前
深入浅出 Elasticsearch:从搜索框到精准排序的架构实战
java·开发语言·elasticsearch·缓存·架构·全文检索·es
我才是一卓7 小时前
linux 安装简易 git 服务端并使用
linux·运维·git
IDIOT___IDIOT8 小时前
关于 git 进行版本管理的时候 gitignore 写入忽略规则而不生效的问题
大数据·git·elasticsearch
不想看见4048 小时前
Git 误删急救手册
大数据·git·elasticsearch
偷懒下载原神9 小时前
【linux操作系统】信号
linux·运维·服务器·开发语言·c++·git·后端
IT二叔9 小时前
Git Flow03-发布流程
git