Skip to content

SSH doesn't work with remotes not named 'origin' #2710

Closed

Description

@rrama

Introduction

Checking out to a branch when your remote is not named origin fails when using SSH authentication.

Similar issues

#2661, #2273 (and all the issues referenced by it), and #2169

Error log

https://gist.github.com/rrama/eb43f8b84f72c4cc93724cb1574d70cc

Steps to reproduce

Pre-requisites

  1. Setup your SSH key with GitHub and install Git LFS.

  2. This step can be skipped if you're willing to use my repository for testing.
    The repository needs to include a file tracked with Git LFS in a branch other than master. This file must not exist on master (this is to ensure a fresh download not from the local cache).

Steps

Copy/pasteable example at the bottom

  1. Clone the repository with SSH git clone [email protected]:Org_Name/Repo_Name.git
  2. Change directory into the clones repository. cd Repo_Name
  3. Rename the remote to anything by origin. git remote rename origin remote_name
  4. Checkout the to the branch with the large file. git checkout remote_name/branch_name --

For example:

git clone [email protected]:rrama/Test.git
cd Test/
git remote rename origin upstream
git checkout upstream/large_file_0 --

Expected outcome

The outcome should be the same as if you ran the steps without step 3.
E.g.

git clone [email protected]:rrama/Test.git
cd Test/
git checkout origin/large_file_0 --

Side effect of the error

The failure occurs after the regular (non-Git LFS tracked) files have been "checked out" (placed in the working directory), but before the branch has been switched. This means that you will still be on the branch you were on before running checkout, but with all the files (except those tracked by Git LFS) of the other branch. This is a nuisance and will require you to either manually correct the incorrect files or hope git reset --hard HEAD && git clean -fdq doesn't delete anything you didn't account for.

Activity

  1. technoweenie commented on Nov 2, 2017

    @technoweenie
    Contributor

    LFS uses Git's smudge filter to replace LFS pointers during git checkout. However, the context of which Git remote was used to pull info is not passed to LFS. So, the best LFS can do is go by the tracked branch. I just implemented that here: #2700

    LFS will check the branch.{name}.remote property, which should be set automatically when you create a tracking branch. I'm not sure if there's any way to get this info from a command like git checkout origin/large_file_0 --. You may have to do something like this:

    $ git clone [email protected]:rrama/Test.git
    $ cd Test
    $ git remote rename origin upstream
    
    # This may take a bit since it's downloading the file in the bg
    $ git checkout -t upstream/large_file_0
    $ cat .git/config
    [branch "master"]
    	remote = upstream
    	merge = refs/heads/master
    [branch "large_file_0"]
    	remote = upstream
    	merge = refs/heads/large_file_0

    If you like, I can provide a custom master build so you can try it out.

  2. haochenx commented on Dec 10, 2017

    @haochenx

    I was also getting this problem today and my scenario is that I was cloning a repository that contains LFS objects with command git clone -o<remote_name> <repo url>. The clone failed barking

    Error downloading object: <file path in repo> (******30): Smudge error: Error downloading <file path in repo again> (*****************30): batch request: missing protocol: ""
    

    I had to set lfs.url manually and the solution was only discovered after some hard research. The UX was horrible in this case, and I think there should be a fix.

    In the case of initial cloning, it is obvious that there will be only one remote, and I think LFS could just look up the URL of the single remote and try to pull from. If it fails, at least the error message should suggest a fix (i.e. setting lfs.url).

  3. fire commented on Jan 16, 2018

    @fire

    this breaks git-repo. This means only one git-repo server (hosting n git repos) can have lfs.

    For instance we can call github origin and put all the lfs repos there, but gitlab (called mine) will be unable to use git-lfs.

  4. ttaylorr commented on May 29, 2018

    @ttaylorr
    Contributor

    Moving to: #1053.

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