{"id":18330557,"url":"https://github.com/zhxxch/git-lfs-one","last_synced_at":"2025-10-29T13:20:40.315Z","repository":{"id":63938594,"uuid":"289643559","full_name":"zhxxch/git-lfs-one","owner":"zhxxch","description":"Serverless Git LFS on Aliyun \u0026 Git LFS host on OneDrive","archived":false,"fork":false,"pushed_at":"2022-05-21T06:53:45.000Z","size":53,"stargazers_count":33,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T15:45:22.100Z","etag":null,"topics":["git-lfs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhxxch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-23T08:11:41.000Z","updated_at":"2025-01-13T17:16:29.000Z","dependencies_parsed_at":"2023-01-14T15:30:52.478Z","dependency_job_id":null,"html_url":"https://github.com/zhxxch/git-lfs-one","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhxxch%2Fgit-lfs-one","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhxxch%2Fgit-lfs-one/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhxxch%2Fgit-lfs-one/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhxxch%2Fgit-lfs-one/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhxxch","download_url":"https://codeload.github.com/zhxxch/git-lfs-one/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423496,"owners_count":20936622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git-lfs"],"created_at":"2024-11-05T19:23:35.492Z","updated_at":"2025-10-29T13:20:40.217Z","avatar_url":"https://github.com/zhxxch.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git LFS Serverless \u0026 [Git LFS One](https://lfs-one.inv.ariant.cn)\n\n完全弹性伸缩的Git LFS服务器。\n\n由阿里云对象存储（OSS）、函数计算（FC）、表格存储（OTS）支持。\n\n以极低成本自由搭建仓库数目不限、容量不限的LFS服务。\n\n∘ [安装](#资源栈模板安装) ∘ [客户端设置](#客户端设置) ∘ [卸载](#卸载) ∘ [注意事项](#其他注意事项) ∘ \n\n∘ [使用OneDrive托管并发布公共LFS仓库（Git LFS One）](https://lfs-one.inv.ariant.cn)\n\n## 资源栈模板安装\n\n确保阿里云账户开通了对象存储、函数计算、表格存储、访问控制和资源编排服务。\n\n1. 选择地域、在资源编排控制台创建资源栈；\n\n2. 选择模板录入方式：使用url；输入[https://cdn.jsdelivr.net/gh/zhxxch/git-lfs-one@latest/lfs-oss-template.json](https://cdn.jsdelivr.net/gh/zhxxch/git-lfs-one@latest/lfs-oss-template.json)\n\t\n\t获取JSON内容后点击下一步；\n\n3. 设置LFS的默认用户名和密码。点击“创建”。\n\n\t![install-steps](https://i.loli.net/2020/07/27/AEn4wOalpSYCZNg.png)\n\n4. 资源栈创建完成后，输出选项卡中将显示LFS服务的远程地址（Endpoint），需要使用此地址[配置Git LFS客户端](#客户端设置)。\n\n## 客户端设置\n\n（Git LFS的使用可以参考[Git LFS 操作指南（Gitee）](https://gitee.com/help/articles/4235)、[git-lfs/git-lfs/wiki/Tutorial](https://github.com/git-lfs/git-lfs/wiki/Tutorial)）\n\n建立仓库；开启LFS：\n```\ngit init\ngit lfs install\n```\n\n设置LFS远程地址：\n```\ngit config --local lfs.url \u003cEndpoint URL\u003e\n```\n也可以`.lfsconfig`文件中设置远程地址：\n```\ngit config --file=.lfsconfig lfs.url \u003cEndpoint URL\u003e\ngit add .lfsconfig\n```\n`.lfsconfig`文件提交到仓库中则克隆仓库时LFS自动读取`.lfsconfig`并下载文件。\n\n### 远程地址的格式\n\n`\u003cEndpoint URL\u003e`实际地址可以在资源栈“输出”选项卡中查看，例如：\n```\nhttps://######.fc.aliyuncs.com/2016-08-15/proxy/service/function/{******}.git/info/lfs\n```\n\n其中`{******}`部分可以任意填写作为仓库名。如果设置远程地址为`https://....../Repo.git/info/lfs`，上传的文件将位于OSS存储桶的`/Repo.git/lfs.objects/`文件夹中。\n\n通过为不同仓库的客户端设置不同的远程地址，各仓库LFS管理的文件可以存储在不同目录中，无需服务器端为此个别配置。\n\n## 其他服务器设置\n\n### 客户端认证\n\n地址中`username:password`是HTTP认证部分的“用户名:密码”。为服务器端仓库添加用户或更改用户名与密码的方式是：编辑OSS存储桶中仓库目录下的`lfs.htpasswd.json`文件。示例：\n```\n[\n\t\"user001:{SHA}DMfOUZZzqxOm6a0yb0+6RDorH/4=\",\n\t\"contrib:{SHA}Ki8e1bdA8S2EvNh24SP7+7gjKRc=\"\n]\n```\n仅支持SHA-1。此文件中默认保存了创建资源栈时设置的用户名和密码。\n\n可以使用[这个工具](https://tool.oschina.net/htpasswd)在线生成htpasswd。\n\n**未认证的用户仍可以下载文件**（前提是拥有对应的Git仓库），上传和使用文件锁功能必须提供正确的用户名和密码。\n\n如果希望架设一个仅供克隆和拉取且可公开访问的LFS仓库，推荐使用[Git LFS One](#Git-LFS-One)将LFS文件托管在OneDrive中，并获得一个用于LFS拉取（pull）的URL。\n\n### 绑定自定义域名\n\n如果将自定义域名`my-domain.net`与路径`/xxx/xxxx/*`绑定至函数，则对应`MyRepository`仓库的LFS远程地址是：\n```\nhttps://username:password@my-domain.net/xxx/xxxx/MyRepository.git/info/lfs\n```\n\n## 管理远程文件\n\nGit LFS协议仅能够上传、下载，没有提供删除服务器端文件的手段，如果希望本地LFS管理的内容与服务器端存储的内容完全一致，最简单的方法是使用`git lfs fetch --all`将文件全部下载到本地，然后清空服务器中当前仓库的所有文件（即删除存储桶中的对应目录，本软件没有提供这项功能，需要通过控制台或API操作），再通过`git lfs push --all`重新上传。\n\n## 卸载\n\n1. 删除LFS使用的存储桶中的所有文件；\n2. 清空表格存储相关表格中的数据（如果使用了文件锁）；\n3. 在资源栈列表中删除资源栈。\n\n卸载本地仓库的LFS请参考[git-lfs/git-lfs#3026](https://github.com/git-lfs/git-lfs/issues/3026)。\n\n## 合并代码与资源栈模板\n\n脚本`Build-Template.ps1`将函数的代码打包为zip，以base64编码写入资源栈模板中。此脚本可能需要在Windows系统中运行。\n```\n./Build-Template.ps1 ./lfs-oss.js ./template-code-incomplete.json ./lfs-oss-template.json\n```\n\n*******\n\n## 【其他注意事项】\n\n1. **无法上传大于5GB的单个文件**\n\n\t本地的Git LFS客户端直接向OSS发送PUT请求上传文件，OSS API有5GB的限制。改进这一限制必须分片上传，Git LFS客户端自身无法做到这一点。（此外Git for Windows无法处理大于4GB的文件：[git-for-windows/git#1063](https://github.com/git-for-windows/git/issues/1063)）\n\n2. 使用本软件部署Git LFS服务不会产生费用。但是使用过程中的计费项包括表格存储；对象存储的请求数、网络流量、存储容量；和函数计算的请求数、网络流量、执行时间**需要您自行承担费用！**\n\n\tGit LFS协议的特性造成请求数、函数计算的流量和执行时间费用可忽略不计；考虑到OSS上传流量不计费，总成本主要由OSS存储以及OSS或CDN下行流量费用构成，几乎所有情况下都低于单纯由云服务器支持的Git LFS服务。\n\n\t如果不希望此服务器造成过大的LFS下行流量，可以使用[Git LFS One](#Git-LFS-One)将仓库托管在OneDrive上。\n\n3. 远程地址是互联网可公开访问的，为避免大量开支，建议设置[按量实例伸缩控制](https://help.aliyun.com/document_detail/144516.html)。\n\n4. 不建议在相关存储桶中存放其他文件。\n\n*******\n\n## 反馈\n\n故障报告、建议请通过[Issues](https://github.com/zhxxch/git-lfs-one/issues)提出，其他事项请联系zhxxch at outlook dot com。\n\n## 使用许可\n\nGPL-3.0\n\n*******\n\n# [Git LFS One](https://lfs-one.inv.ariant.cn)![git-lfs-one.png](https://i.loli.net/2020/07/27/VUs9waQ3eNjIJvB.png)\n\n开始使用Git LFS One：[https://lfs-one.inv.ariant.cn](https://lfs-one.inv.ariant.cn)\n\n∘ [使用条款](https://lfs-one.inv.ariant.cn/Terms-of-Use) ∘ [隐私声明](https://lfs-one.inv.ariant.cn/Privacy-Statement) ∘\n\n## OneDrive与Git LFS One的连接\n\nGit LFS One能够将OneDrive中的特定文件夹转换成公开的Git LFS仓库。普通的Git LFS客户端均可以通过lfs.v.ariant.cn提供的地址拉取OneDrive中的LFS文件。\n\n1. 登录并授权后，本应用为OneDrive账户生成一个LFS远程地址；（示例）`https://lfs.v.ariant.cn/jKZN6***I6c/`\n\n2. 进入应用在OneDrive创建的目录`Git-LFS-One/`（本应用仅具有对此文件夹的访问权限）；\n\n3. 新建文件夹并使用`git init --bare`初始化仓库；\n\n\t```\n\tcd Git-LFS-One\n\tmkdir \u003crepository-name\u003e\n\tcd \u003crepository-name\u003e\n\tgit init --bare\n\t```\n\n4. 在本地Git仓库将OneDrive中的文件夹（本地路径）添加为远程仓库；\n\n\t```\n\tgit remote add onedrive C:/.../.../Git-LFS-One/\u003crepository-name\u003e/\n\t```\n\n5. 执行`git lfs push --all onedrive`上传LFS文件；\n\n6. 其他Git LFS客户端可以将本应用提供的地址添加为远程仓库（`remote`）从而提取LFS管理的文件（`pull`、`fetch`）。\n\n\t```\n\tgit remote add onelfs https://lfs.v.ariant.cn/######/\u003crepository-name\u003e.git\n\tgit lfs fetch onelfs\n\t```\n\n例如\n```\nhttps://lfs.v.ariant.cn/######/repository-folder.git\n```\n对应OneDrive中\n```\n~/OneDrive/Apps/Git-LFS-One/repository-folder/\n```\n或\n```\n~/OneDrive/应用/Git-LFS-One/repository-folder/\n```\n请在`repository-folder`目录下执行`git init --bare`并将LFS文件推送至此仓库中；或直接复制本地仓库的`.git/lfs`目录到`repository-folder`文件夹中。\n\nOneDrive中应该具有如下目录结构：\n```\nOneDrive\n+---应用（或“Apps”）\n   \\---Git-LFS-One\n       \\---\u003crepository-folder\u003e\n           +---hooks\n           +---info\n           +---lfs\n           |   \\---objects\n           |       +---HH\n           |       |   \\---HH\n           +---objects\n           |   +---info\n           |   \\---pack\n           \\---refs\n               +---heads\n               \\---tags\n```\n\n********\n\n本软件得到了“Git推广普及计划”“Git LFS惠民工程”“云计算进乡村促发展”（这些都不存在的）项目的资助。[GitHub](https://github.com/zhxxch/git-lfs-one) ∘ [Gitee](https://gitee.com/zhxxch/git-lfs-one)\n\n[*点击此处取消Git LFS One与OneDrive账户的连接*](https://account.live.com/consent/Manage)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhxxch%2Fgit-lfs-one","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhxxch%2Fgit-lfs-one","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhxxch%2Fgit-lfs-one/lists"}