Is there a way to push git lfs to bare repository

2.2k views Asked by At

Describe the issue cannot push to the bare repository

I'm new to git, and I don't know if my operation is right.

  1. create a bare repo in computer A, and install lfs, and then share the folder to the local network
  2. clone the bare repo to computer B and install lfs, track the files using git lfs track "*.psd"
  3. git add . and git commit -m 'lfs setup'
  4. make some changes to psd files
  5. git add . and git commit -m 'some changes'
  6. git push origin master

And then... ...

$ 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>'

I don’t know if there is such a way that can fix the problem?

Output of git lfs env

git lfs env in bare repo:

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 in the working repo (non bare):

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"

3

There are 3 answers

0
Simon Doppler On

Git LFS is an extension to Git, it is not part of git itself. It is basically a HTTP server which stores the large files, while only metadata gets pushed to the repository. The LFS server API is documented here.

If you want to work with a local bare repository, you can use lfs-test-server to be a local LFS server. It is only supposed to be used for testing purposes and is NOT PRODUCTION READY. If you need a production-ready LFS server, you should look into self-hosting a Gitlab or Gitea instance (they can be hosted on your local machine if needed).

1
bk2204 On

Git LFS supports local file URLs and can push objects to and from a local repository, but it doesn't currently handle the Windows SMB path syntax. That's because none of the core developers use that functionality and nobody has sent a patch to implement it.

The next release of Git LFS, 3.0.0, should handle it correctly if you assign the SMB share a drive letter, and it will also support a connection over SSH if you install a suitable server on the remote side. The former is already available in the main branch and the latter will be soon.

0
M463 On

I ran into this issue today and as @bk2204 pointed out, it was an issue with the SMB paths.

enter image description here

I was ultimately able to resolve it with the information available from this github issue. I added an .lfsconfig file with the following content into the root directory of my local repository and pushed it before I pushed the actual LFS files:

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

Note the file://// prefix, that's the important part - using // won't work.