Skip to content

git clone file://somelocal-lfs-repo does not work... #724

Closed

Description

@tvandijck
  • create a new repository locally, without any remote.
  • lfs track some files.
  • add some files
  • git commit

got to a different location..

git clone file://localrepo name2

Errors logged to .git\lfs\objects\logs\20151008T171907.6430782.log
Use git lfs logs last to view the log.
Downloading packages/blz/2.4.1-sc2/noarch/src/math.cpp (1.42 KB)
Error accessing media: packages/blz/2.4.1-sc2/noarch/src/math.cpp (ca8d92a9a6c9595749e0120116020ea2c4c3a8fb7b58e3f01abf9
459b4553c00)

neither repo has a remote at this point, and purely exists locally...

Activity

  1. technoweenie commented on Oct 9, 2015

    @technoweenie
    Contributor

    Git LFS requires a web server to talk to. It gets the web server address by converting an HTTPS or SSH remote, but doesn't know what to do with a file remote. You can set one explicitly:

    # set it for a specific remote in the repo
    $ git config remote.{remote-name}.lfsurl https://some-git-lfs-server.com
    
    # sets it for all remotes in the repo
    $ git config lfs.url https://some-git-lfs-server.com
  2. tvandijck commented on Oct 9, 2015

    @tvandijck
    Author

    I see, but would that server not have the content either? since I never pushed anything?
    I guess what I was hoping for is that in a local clone, it would just refer to the local lfs/objects folder.

  3. tvandijck commented on Oct 9, 2015

    @tvandijck
    Author

    Yeah, as expected... I added a remote, never pushed a thing... same error...

    git-lfs/1.0.0 (GitHub; windows amd64; go 1.5.1; git 7379fa9)
    git version 2.5.0.windows.1
    
    $ git-lfs.exe smudge packages/GoldEngine/5.0.4-src/noarch/include/GoldEngine/AST/Object.h
    Error accessing media: packages/GoldEngine/5.0.4-src/noarch/include/GoldEngine/AST/Object.h (efc3d017628876630e007fd258a252c92812ea8314ac6d6f6d4a005ba71eadcb)
    
    Get file:///d/test/lfs-test.git/info/lfs/objects/efc3d017628876630e007fd258a252c92812ea8314ac6d6f6d4a005ba71eadcb: unsupported protocol scheme "file"
    goroutine 1 [running]:
    github.com/github/git-lfs/lfs.Stack(0x0, 0x0, 0x0)
        C:/Users/techn/go/src/github.com/github/git-lfs/lfs/errors.go:557 +0x87
    github.com/github/git-lfs/commands.logPanicToWriter(0x26741e8, 0xc082130018, 0x2eb0278, 0xc08212e250)
        C:/Users/techn/go/src/github.com/github/git-lfs/commands/commands.go:184 +0xf86
    github.com/github/git-lfs/commands.logPanic(0x2eb0278, 0xc08212e250, 0x0, 0x0)
    
  4. technoweenie commented on Oct 9, 2015

    @technoweenie
    Contributor

    What does git lfs env show?

  5. tvandijck commented on Oct 9, 2015

    @tvandijck
    Author
    git-lfs/1.0.0 (GitHub; windows amd64; go 1.5.1; git 7379fa9)
    git version 2.5.0.windows.1
    
    Endpoint=https://ghosthub.corp.blizzard.net/tdijck/lfs-test.git/info/lfs (auth=none)
      [email protected]:tdijck/lfs-test.git
    LocalWorkingDir=D:\test\lfs-test
    LocalGitDir=D:\test\lfs-test\.git
    LocalGitStorageDir=D:\test\lfs-test\.git
    LocalMediaDir=D:\test\lfs-test\.git\lfs\objects
    TempDir=D:\test\lfs-test\.git\lfs\tmp
    ConcurrentTransfers=3
    BatchTransfer=false
    git config filter.lfs.smudge = "git-lfs smudge %f"
    git config filter.lfs.clean = "git-lfs clean %f"
    

    and actually, I just pushed the entire repo to the server, and tried it again:

    git clone file:///d/test/lfs-test lfs-test5
    

    same errors.... so even with the remote setup in the source repository, and all files uploaded to the server, a local clone does not function.

  6. technoweenie commented on Oct 9, 2015

    @technoweenie
    Contributor

    That's the lfs env from the repository clone that didn't work? That shows an SSH remote.

    You have several options that could work:

    If you're going to be cloning from local paths a lot, you can commit the lfs.url config setting to .gitconfig in your repo. But, this means that everyone will have the same url there. So this may not be your best solution. You can do that like this: git config --file .gitconfig lfs.url booya. This is not a standard config file location that Git reads, but Git LFS will read it. You can verify with git lfs env.

    You can also disable automatic downloading. Perhaps have a script that clones a repo, sets up the lfs url, and pulls?

    $ GIT_LFS_SKIP_SMUDGE=1 git clone file:///d/test/lfs-test lfs-test5
    $ cd lfs-test5
    $ git config remote.origin.lfsurl https://ghosthub.corp.blizzard.net/tdijck/lfs-test.git/info/lfs
    $ git lfs pull

    At this point, everything should be setup.

    A third option is to try out the new git worktree feature. This requires Git 2.5+. I haven't worked with it too much, but it lets you setup multiple working directories from a single local clone. Git LFS automatically supports this by looking for files in the .git/lfs/objects dir of the worktree's bare git repo.

  7. tvandijck commented on Oct 9, 2015

    @tvandijck
    Author
    tdijck@TVANDIJCK-W10 MINGW64 /d/test
    $ GIT_LFS_SKIP_SMUDGE=1 git clone file:///d/test/lfs-test lfs-test5
    Cloning into 'lfs-test5'...
    remote: Counting objects: 439, done.
    remote: Compressing objects: 100% (428/428), done.
    Receiving objects: 100% (439/439), 96.15 KiB | 0 bytes/s, done.
    Resolving deltas: 100% (4/4), done.
    remote: Total 439 (delta 4), reused 0 (delta 0)
    Checking connectivity... done.
    Checking out files: 100% (409/409), done.
    
    tdijck@TVANDIJCK-W10 MINGW64 /d/test
    $ cd lfs-test
    
    tdijck@TVANDIJCK-W10 MINGW64 /d/test/lfs-test (master)
    $ cd ../lfs-test5
    
    tdijck@TVANDIJCK-W10 MINGW64 /d/test/lfs-test5 (master)
    $ git config remote.origin.lfsurl https://ghosthub.corp.blizzard.net/tdijck/lfs-test.git/info/lfs
    
    tdijck@TVANDIJCK-W10 MINGW64 /d/test/lfs-test5 (master)
    $ git lfs pull
    (0 of 358 files) 0 B / 2.90 MB
    Invalid status for POST https://ghosthub.corp.blizzard.net/tdijck/lfs-test.git/info/lfs/objects/batch: 403
    Invalid status for POST https://ghosthub.corp.blizzard.net/tdijck/lfs-test.git/info/lfs/objects/batch: 403
    Invalid status for POST https://ghosthub.corp.blizzard.net/tdijck/lfs-test.git/info/lfs/objects/batch: 403
    Invalid status for POST https://ghosthub.corp.blizzard.net/tdijck/lfs-test.git/info/lfs/objects/batch: 403
    

    the worktree feature obviously works...

  8. technoweenie commented on Oct 9, 2015

    @technoweenie
    Contributor

    Try disabling the batch API. The client doesn't seem to be detecting that the batch API isn't implemented on your instance. That sucks :(

    $ git config lfs.batch false

    You can confirm this by looking for "BatchTransfer=false" in git lfs env.

  9. tvandijck commented on Oct 9, 2015

    @tvandijck
    Author

    We turned off the batch API globally in git, so that was already the case.

    BatchTransfer=false
    
  10. technoweenie commented on Oct 9, 2015

    @technoweenie
    Contributor

    Can you show me git lfs env from the lfs-test5 repo? I've confirmed that disabling batch should work:

    # already disabled
    $ git lfs env | grep Batch                     
    BatchTransfer=false
    
    # clear objects to force it to download again
    $ rm -rf .git/lfs/objects
    
    $ GIT_TRACE=1 git lfs pull | grep "lfs/objects"
    trace git-lfs: HTTP: GET https://github.com/github/git-lfs-test.git/info/lfs/objects/b9f86fab477109565871ced361ba69f2425a91fbe6057fa7a9629a8d536d7c71
    trace git-lfs: HTTP: GET https://github-cloud.s3.amazonaws.com/alambic/media/111976139/b9/f8/b9f86fab477109565871ced361ba69f2425a91fbe6057fa7a9629a8d536d7c71?actor_id=21
    trace git-lfs: HTTP: GET https://github.com/github/git-lfs-test.git/info/lfs/objects/55d51edb307ed7bf4a1bbca3867d132a07f76828d57f37e0f31f712c02ceafe0
    trace git-lfs: HTTP: GET https://github.com/github/git-lfs-test.git/info/lfs/objects/d1c8fab51418ef587fcf5dd8e73c60b9700704e2f8f5292ea12ec27c285b23a3
    trace git-lfs: HTTP: GET https://github-cloud.s3.amazonaws.com/alambic/media/111976139/55/d5/55d51edb307ed7bf4a1bbca3867d132a07f76828d57f37e0f31f712c02ceafe0?actor_id=21
    trace git-lfs: HTTP: GET https://github-cloud.s3.amazonaws.com/alambic/media/111976139/d1/c8/d1c8fab51418ef587fcf5dd8e73c60b9700704e2f8f5292ea12ec27c285b23a3?actor_id=21

    Notice that the client is hitting lfs/objects/{oid} once for each object, and also making an S3 request for each object. This is what it looks like when I turn batch transfers back on:

    $ git config --unset lfs.batch
    $ git lfs env | grep Batch    
    BatchTransfer=true
    
    # clear objects to force it to download again
    $ rm -rf .git/lfs/objects    
    
    $ GIT_TRACE=1 git lfs pull | grep "lfs/objects"
    trace git-lfs: HTTP: POST https://github.com/github/git-lfs-test.git/info/lfs/objects/batch
    trace git-lfs: HTTP: 200
    trace git-lfs: HTTP: GET https://github-cloud.s3.amazonaws.com/alambic/media/111976139/b9/f8/b9f86fab477109565871ced361ba69f2425a91fbe6057fa7a9629a8d536d7c71?actor_id=21
    trace git-lfs: HTTP: GET https://github-cloud.s3.amazonaws.com/alambic/media/111976139/55/d5/55d51edb307ed7bf4a1bbca3867d132a07f76828d57f37e0f31f712c02ceafe0?actor_id=21
    trace git-lfs: HTTP: GET https://github-cloud.s3.amazonaws.com/alambic/media/111976139/d1/c8/d1c8fab51418ef587fcf5dd8e73c60b9700704e2f8f5292ea12ec27c285b23a3?actor_id=21

    Now it's making one API call to "info/lfs/objects/batch", and then one to download each specific file from S3. Of course, yours won't be getting them from S3. But the ratio of requests should be the same. 1 batch request for every 100 files, and then one request to download each individual file (as opposed to a 1 to 1 mapping of LFS requests and download requests as shown above).

  11. tvandijck commented on Oct 9, 2015

    @tvandijck
    Author

    ok, so you are right, it was actually true for that repo... so after fixing that I get:

    tdijck@TVANDIJCK-W10 MINGW64 /d/test/lfs-test5 (master)
    $ git config --global lfs.batch false
    
    tdijck@TVANDIJCK-W10 MINGW64 /d/test/lfs-test5 (master)
    $ git lfs env
    git-lfs/1.0.0 (GitHub; windows amd64; go 1.5.1; git 7379fa9)
    git version 2.5.0.windows.1
    
    Endpoint=https://ghosthub.corp.blizzard.net/tdijck/lfs-test.git/info/lfs (auth=none)
    LocalWorkingDir=D:\test\lfs-test5
    LocalGitDir=D:\test\lfs-test5\.git
    LocalGitStorageDir=D:\test\lfs-test5\.git
    LocalMediaDir=D:\test\lfs-test5\.git\lfs\objects
    TempDir=D:\test\lfs-test5\.git\lfs\tmp
    ConcurrentTransfers=3
    BatchTransfer=false
    git config filter.lfs.smudge = "git-lfs smudge %f"
    git config filter.lfs.clean = "git-lfs clean %f"
    
    tdijck@TVANDIJCK-W10 MINGW64 /d/test/lfs-test5 (master)
    $ git lfs pull
    (0 of 358 files) 0 B / 2.90 MB
    

    doesn't look like it's pulling any files...

  12. tvandijck commented on Oct 9, 2015

    @tvandijck
    Author

    running it with GIT_TRACE=1 I get

    trace git-lfs: HTTP: GET https://ghosthub.corp.blizzard.net/tdijck/lfs-test.git/info/lfs/objects/ccd8488b98b38acf6621467
    5eb817a0c41ff0b3d792ebd8e889d4704b3503819
    trace git-lfs: HTTP: 403
    
  13. technoweenie commented on Oct 9, 2015

    @technoweenie
    Contributor

    A 403 means you're not authenticating properly. Do you have an http credential cacher setup?

    https://help.github.com/articles/caching-your-github-password-in-git/#platform-windows

    Microsoft just released a new one: https://github.com/Microsoft/Git-Credential-Manager-for-Windows. No clue how that works.

    Or, are you purely using SSH for git authentication?

  14. tvandijck commented on Oct 9, 2015

    @tvandijck
    Author

    purely using SSH.

  15. technoweenie commented on Oct 9, 2015

    @technoweenie
    Contributor

    Okay. Try turning off the lfs.url config setting. You only should've needed that when the remote was a file:// url. One of your earlier env output should work:

    Endpoint=https://ghosthub.corp.blizzard.net/tdijck/lfs-test.git/info/lfs (auth=none)
      [email protected]:tdijck/lfs-test.git
    

    With that setup, Git LFS will get a temporary token from SSH before hitting the LFS API.

  16. tvandijck commented on Oct 9, 2015

    @tvandijck
    Author

    removing that from the gitconfig for that repo makes the endpoint go back to file://

    basically the cloned repository does not have a remote setup, so just configuring the endpoint will not setup the SSH= part, and hence does not setup the authentication part.. The conclusion really is that, even though you can make a local clone by disabling a whole bunch of stuff, once the local clone is there, you have to completely replicate all remotes and endpoints to make git lfs work... I might as well have just pulled from the remote directly...

    The only functional way I see right now to use "copies" would be to use the worktree feature..
    which is OK btw... but my opinion still is that

    git clone file://somerepo 
    

    should just work.... and whether that needs for you to implement the "file" protocol, or for LFS to correctly copy the settings to connect to the right remote based on the source repository, I leave up to you...

  17. technoweenie commented on Oct 9, 2015

    @technoweenie
    Contributor

    Oh, I thought you were in a worktree. That seems to be the preferable option for having multiple clones of a repository locally. Seems to make sense in cases where you might want multiple branches checked out at the same time. Worktrees would ensure that you have a single .git with one copy of your git and your lfs objects.

    I definitely agree that file:// support would be nice too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions