Skip to content

Supporting multiple remotes from git pull #436

Closed

Description

@technoweenie

Is there any way to know what remote we're pulling from in Git LFS commands?

$ git remote add something <url>
$ git pull remote master
# git lfs smudge...

Git LFS has no idea what remote was pulled from in the smudge command, so it defaults to origin. I don't think the post-checkout hook will help either:

This hook is invoked when a git checkout is run after having updated the worktree. The hook is given three parameters: the ref of the previous HEAD, the ref of the new HEAD (which may or may not have changed), and a flag indicating whether the checkout was a branch checkout (changing branches, flag=1) or a file checkout (retrieving a file from the index, flag=0). This hook cannot affect the outcome of git checkout. -- http://git-scm.com/docs/githooks

I think as a work around, we'll do the following:

  1. Add remote support to git lfs fetch
  2. Add git lfs pull which is basically git pull + git lfs fetch

@mhagger: Any thoughts?

Activity

  1. rubyist commented on Jun 24, 2015

    @rubyist
    Contributor

    This is probably a bad idea, but I'll toss it out anyway. Wondering if it's possible to parse .git/logs/HEAD (or whatever) from the post-checkout:

    16108cee8a4e10edc2b36bb871289bb98a060008 77d3aacf3fdfd9a32fe8eb40647eb3e57307a7ae rubyist <[email protected]> 1435163862 -0500    pull dev master: Fast-forward
    
  2. michael-k commented on Jun 24, 2015

    @michael-k
    Contributor

    For git pull we could use GIT_REFLOG_ACTION=pull <remote> <branch>, but that is not the case to solve, git checkout is.

    Btw., it's not only about supporting multiple remotes, it's also about supporting repos with a single remote which is not named origin. Git LFS doesn't support that use case.

  3. mhagger commented on Jun 25, 2015

    @mhagger
    Contributor

    @technoweenie: I can't think of any tricks to help here, unless perhaps there happens to be some magic environment variable that gets set before calling the filter.

    I can understand the inconvenience of trying to use LFS with a remote that is not called origin. But it is easy to configure around that problem, I would think?

    But I'm having a little trouble understanding how LFS could possibly work with more than one remote at the same time. There are many contexts when the filters are run without any connection to a remote. For example, I can git checkout $SHA1. Git can't know where that SHA-1 came from so how can it possibly know which of multiple LFS servers it should use to fetch large objects?

    I think LFS is by its nature limited to working with a single LFS server per repository.

  4. whoisj commented on Jun 25, 2015

    @whoisj

    @mhagger, @technoweenie maybe the solution isn't deciding which LFS remote is correct per Git remote but having a series of them, potentially, which allow fallback to get the binaries as needed. Since the files are named uniquely based on content hashes it doesn't matter which LFS remote the content is fetched from, so long as it is available.

    Perhaps only supporting a single default LFS remote on push is correct, because I cannot see how anyone would want to push to multiple if they didn't need to.

  5. michael-k commented on Jun 25, 2015

    @michael-k
    Contributor

    I haven't tried it, but we shouldn't have problems with push, as we know which remote is being pushed to. git lfs pre-push and git lfs push require both a remote as argument.

  6. gully commented on Feb 25, 2016

    @gully

    I'm a bit confused here. Imagine the following use cases:

    1. I want to store my repo on GitHub, but I want the large files to be stored on a local computer with ssh. This avoids having to rack up GitHub bandwidth costs, for example.

    2. I want to store my repo on GitHub with some of the large files (e.g. demo data), but I want some other large files (e.g. proprietary data) to be stored on another remote.

    Are these two use cases supported with the current git LFS?

    Is the following workflow possible?
    git lfs pulls from the GitHub remote, and then pulls from a second remote if it is available.

  7. technoweenie commented on Feb 25, 2016

    @technoweenie
    ContributorAuthor

    I want to store my repo on GitHub, but I want the large files to be stored on a local computer with ssh. This avoids having to rack up GitHub bandwidth costs, for example.

    Yeah, but not easily. You'll have to maintain a fair amount of stuff (SSH, custom git-lfs-authenticate script, custom LFS server).

    I want to store my repo on GitHub with some of the large files (e.g. demo data), but I want some other large files (e.g. proprietary data) to be stored on another remote.

    That's possible, by being careful about what branches you push to which remotes. Seems like it'd be easy to mess up.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions