【问题标题】:Initialize bare git repository with LFS使用 LFS 初始化裸 git 存储库
【发布时间】:2017-06-23 23:20:33
【问题描述】:

我想在支持 git LFS 协议的外部驱动器 (git init --bare reponame) 上初始化几个本地 git 存储库。 IE。克隆这些之后,我希望能够通过 LFS 跟踪大文件(文件的版本应该存储在外部驱动器上)

在没有任何额外步骤的情况下这样做是行不通的(即克隆空仓库,使用 git LFS 跟踪大文件,并尝试推送到远程):

Git LFS: (0 of 122 files) 0 B / 157.56 MB
http: Post /media/me/bigdrive/git_repos/coding.git/info/lfs/objects/batch:
      unsupported protocol scheme ""
http: Post /media/me/bigdrive/git_repos/coding.git/info/lfs/objects/batch:
      unsupported protocol scheme ""
error: failed to push some refs to '/media/me/bigdrive/git_repos/coding'`

我没有找到有关如何执行此操作的指南,并且 LFS 手册页似乎没有提供解决方案。 GitHub/BitBucket 指南仅说明如何在本地存储库上执行此操作,然后推送到其服务器上正确配置的 git 存储库

感谢任何帮助,谢谢!

【问题讨论】:

    标签: git github git-lfs


    【解决方案1】:

    我有类似的问题,但设法让它工作。

    第 1 步:

    下载并启动一个 LFS 服务器(如果您还没有这样做的话),例如 https://github.com/git-lfs/lfs-test-server(不要在生产中使用这个。)

    第 2 步:

    为您的 repo 正确设置 LFS 服务器 URL,如下所述:https://github.com/git-lfs/git-lfs/wiki/Tutorial#lfs-url

    在我的情况下,在我的工作副本文件夹中运行以下内容就足够了:

    git config -f .lfsconfig lfs.url http://username:password@localhost:8080
    git add .lfsconfig
    

    用你想要的凭据替换用户名和密码,用你的 Git 服务器 URL 替换 localhost:8080。

    您可以运行git lfs env 来验证您的结果。

    第 3 步:

    设置您的 LFS_ADMINUSERLFS_ADMINPASS 环境变量,如下所述:https://github.com/git-lfs/lfs-test-server#running

    然后,您应该可以在浏览器中访问http://localhost:8080/mgmt(或运行 LFS 服务器的任何位置)并添加您的凭据。

    结果看起来很有希望:

    C:\Users\Nick\Desktop\WorkingCopy\Repo>git push origin master
    warning: current Git remote contains credentials
    warning: current Git remote contains credentials
    Git LFS: (1 of 1 files) 6.72 KB / 6.72 KB
    Counting objects: 3, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (3/3), done.
    Writing objects: 100% (3/3), 428 bytes | 0 bytes/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To C:/Users/Nick/Desktop/WorkingCopy/../Repo
       309629f..7fe106d  master -> master
    

    LFS 服务器的 lfs-content 文件夹现在包含一个文件,其大小与添加的文件完全相同。

    【讨论】:

      猜你喜欢
      • 2015-04-02
      • 2016-04-12
      • 1970-01-01
      • 2016-07-30
      • 2014-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-06
      相关资源
      最近更新 更多