有没有办法将git lfs推送到裸存储库

问题描述 投票:0回答:3

描述问题 无法推送到裸存储库

我是git新手,不知道我的操作是否正确。

  1. 在电脑A中创建一个裸repo,并安装lfs,然后将文件夹共享到本地网络
  2. 将裸存储库克隆到计算机 B 并安装 lfs,使用
    git lfs track "*.psd"
  3. 跟踪文件
  4. git add .
    git commit -m 'lfs setup'
  5. 对 psd 文件进行一些更改
  6. git add .
    git commit -m 'some changes'
  7. git push origin master

然后... ...

$ git push
Uploading LFS objects: 100% (4/4), 46 MB | 0 B/s, done.
EOF
error: failed to push some refs to '<bare repo path>'

不知道有没有这样的方法可以解决这个问题?

输出

git lfs env

裸仓库中的 git lfs env:

git-lfs/2.13.3 (GitHub; windows amd64; go 1.16.2; git a5e65851)
git version 2.31.1.windows.1

LocalWorkingDir=
LocalGitDir=<bare repo path>
LocalGitStorageDir=<bare repo path>
LocalMediaDir=<bare repo path>\lfs\objects
LocalReferenceDirs=
TempDir=<bare repo path>\lfs\tmp
ConcurrentTransfers=8
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=<bare repo path>\lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic,lfs-standalone-file
UploadTransfers=basic,lfs-standalone-file
GIT_EXEC_PATH=C:/Program Files/Git/mingw64/libexec/git-core
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"

工作仓库中的 git lfs env(非裸):

git-lfs/2.13.3 (GitHub; windows amd64; go 1.16.2; git a5e65851)
git version 2.31.1.windows.1

Endpoint=file:///<bare repo path> (auth=none)
LocalWorkingDir=
LocalGitDir=D:\lfs-repo\.git
LocalGitStorageDir=D:\lfs-repo\.git
LocalMediaDir=D:\lfs-repo\.git\lfs\objects
LocalReferenceDirs=
TempDir=D:\lfs-repo\.git\lfs\tmp
ConcurrentTransfers=8
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=D:\lfs-repo\.git\lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic,lfs-standalone-file
UploadTransfers=basic,lfs-standalone-file
GIT_EXEC_PATH=C:/Program Files/Git/mingw64/libexec/git-core
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"

git repository push git-lfs bare
3个回答
1
投票

Git LFS 支持本地

file
URL,并且可以将对象推送到本地存储库或从本地存储库推送对象,但它当前不处理 Windows SMB 路径语法。这是因为没有核心开发人员使用该功能,也没有人发送补丁来实现它。

如果您为 SMB 共享分配驱动器号,Git LFS 的下一个版本 3.0.0 应该可以正确处理它,如果您在远程端安装合适的服务器,它还将支持通过 SSH 的连接。前者已经在

main
分支中可用,后者即将推出。


0
投票

Git LFS 是 Git 的扩展,它不是 git 本身的一部分。它基本上是一个存储大文件的 HTTP 服务器,而只有元数据被推送到存储库。 LFS 服务器 API 记录在here

如果您想使用本地裸存储库,可以使用 lfs-test-server 作为本地 LFS 服务器。 它仅应用于测试目的,尚未准备好生产。如果您需要一个生产就绪的 LFS 服务器,您应该考虑自托管 Gitlab 或 Gitea 实例(如果需要,它们可以托管在您的本地计算机上)。


0
投票

我今天遇到了这个问题,正如 @bk2204 指出的那样,这是 SMB 路径的问题。

我最终能够使用这个github问题中提供的信息解决它。 我将包含以下内容的 .lfsconfig 文件添加到本地存储库的根目录中,并在推送实际的 LFS 文件之前推送它:

[lfs]
    url = file:////<ip_of_server>/<path_to_directory>

注意

file:////
前缀,这是重要的部分 - 使用
//
不起作用。

© www.soinside.com 2019 - 2024. All rights reserved.