# Multiple remote with git lfs

**URL:** <https://renku.discourse.group/t/multiple-remote-with-git-lfs/344>\
**Category:** General\
**Created:** [1 June 2021 09:36 UTC](https://renku.discourse.group/t/multiple-remote-with-git-lfs/344 "2021-06-01T09:36:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![firat](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@firat](https://renku.discourse.group/u/firat)\
**Post date:** [1 June 2021 09:36 UTC](https://renku.discourse.group/t/multiple-remote-with-git-lfs/344/1 "2021-06-01T09:36:54Z")

</div>

I work on renkulab, but a collaborator works in a different remote. I can add the different remote without problems. However git LFS is not behaving the same way.  
In particular, when I try to checkout a git LFS file from this other remote, it tries to download, then give a [404] error.

attempt for checking out the git LFS file

```auto
git checkout remote_origin/branch_on_remote -- OBJECT 

```

`OBJECT` corresponds to the path of the file from root of the repo, `remote_origin` is the remote where I’m trying to fetch the git LFS file from.

Error message:

> Downloading OBJECT (273 B)  
> Error downloading object: OBJECT (c902841): Smudge error: Error downloading OBJECT (c902841c5cf3623d8f79985e16412fe436d4ff3a55b0094cfa02947xxxxxxxxx): [c902841c5cf3623d8f79985e16412fe436d4ff3a55b0094cfa02947xxxxxxxxx] Object does not exist on the server or you don’t have permissions to access it: [404] Object does not exist on the server or you don’t have permissions to access it
> 
> Errors logged to project/.git/lfs/logs/20210601T112524.125834236.log  
> Use `git lfs logs last` to view the log.  
> error: external filter git-lfs smudge – %f failed 2  
> error: external filter git-lfs smudge – %f failed  
> fatal: OBJECT: smudge filter lfs failed

I read that git LFS cannot handle multiple remotes, is that really the case? Do I need to download the file and manually add it?

Thanks!  
Firat

Edit: If I use a regular git file for `OBJECT` instead of a git LFS object, it works.

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [1 June 2021 09:41 UTC](https://renku.discourse.group/t/multiple-remote-with-git-lfs/344/2 "2021-06-01T09:41:11Z")

</div>

Hi @firat - can you include the actual commands you used?

---

<div class="post-metadata">

**Author:** ![firat](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@firat](https://renku.discourse.group/u/firat)\
**Post date:** [1 June 2021 09:58 UTC](https://renku.discourse.group/t/multiple-remote-with-git-lfs/344/3 "2021-06-01T09:58:46Z")

</div>

Hi @rrrrrok, I just edited my question to include it, thanks!

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [1 June 2021 10:09 UTC](https://renku.discourse.group/t/multiple-remote-with-git-lfs/344/4 "2021-06-01T10:09:17Z")

</div>

are you sure the LFS objects have been pushed to this other remote? i.e. if you clone that repo by itself, it works?

---

<div class="post-metadata">

**Author:** ![firat](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@firat](https://renku.discourse.group/u/firat)\
**Post date:** [1 June 2021 10:53 UTC](https://renku.discourse.group/t/multiple-remote-with-git-lfs/344/5 "2021-06-01T10:53:12Z")

</div>

Yes, I can confirm it is in the repo and I can pull it if I clone that repo

---

<div class="post-metadata">

**Author:** ![ralf.grubenmann](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/ralf.grubenmann/32/78_2.png) [@ralf.grubenmann](https://renku.discourse.group/u/ralf.grubenmann)\
**Post date:** [2 June 2021 06:44 UTC](https://renku.discourse.group/t/multiple-remote-with-git-lfs/344/6 "2021-06-02T06:44:12Z")

</div>

I think using git LFS with multiple remotes isn’t properly supported by LFS, see

> <https://github.com/git-lfs/git-lfs/issues/2108>
>
> Hi
> I have a bare repo that we use as a cache, and I also want to cache git-lfs …objects.
> So I added a remote for each repo I want to cache and fetch all the remotes using \`git fetch —all\`.
> Next, I run \`git lfs fetch \<remote\> -all\` on every remote to cache git-lfs objects.
> I expected that when I invoke \`git lfs fetch \<remote\> -all\` on remotes without lfs objects the command will exit without error, and on remotes with lfs object, they will.be downloaded without error.
> Here’s an example output. In this repo, we have 3 remotes, where the first one doesn’t have any lfs objects, the second one has 2, and the third one has 3.
> 
> \`\`\`
> $ git lfs fetch remote\_1 —all
> Scanning for all objects ever referenced...
> ✔ 5 objects found
> Fetching objects...
> Git LFS: (0 of 0 files, 5 skipped) 0 B / 0 B, 518.41 MB skipped
> \[ffc681e7ea5700e6a9e531fef6733f0a2d4c76ca1c0d253d02a7a93a34360df8\] Object does not exist on the server: \[404\] Object does not exist on the server
> \[f19b58ef1b00106481b68c9865a52ba532ff458bb32c5df206232320eb801ed1\] Object does not exist on the server: \[404\] Object does not exist on the server
> \[e0c536b6c830be3bec8d2f1d2444d7051de0d4d6ee1156d1011155c53eb6a0ff\] Object does not exist on the server: \[404\] Object does not exist on the server
> \[edf8f7569cee11c9608dd9daa0acc39a3a7b30b2762c674111fe3bcd1fd966fa\] Object does not exist on the server: \[404\] Object does not exist on the server
> \[dbc574ed36b17b5cba86607d1ae442498087f0ee04195993b664c4c18b7ae8e9\] Object does not exist on the server: \[404\] Object does not exist on the server
> Warning: errors occurred
> 
> $ git lfs fetch remote\_2 —all
> Scanning for all objects ever referenced...
> ✔ 5 objects found
> Fetching objects...
> Git LFS: (2 of 2 files, 3 skipped) 290.00 MB / 290.00 MB, 228.41 MB skipped
> \[ffc681e7ea5700e6a9e531fef6733f0a2d4c76ca1c0d253d02a7a93a34360df8\] Object does not exist on the server: \[404\] Object does not exist on the server
> \[edf8f7569cee11c9608dd9daa0acc39a3a7b30b2762c674111fe3bcd1fd966fa\] Object does not exist on the server: \[404\] Object does not exist on the server
> \[dbc574ed36b17b5cba86607d1ae442498087f0ee04195993b664c4c18b7ae8e9\] Object does not exist on the server: \[404\] Object does not exist on the server
> Warning: errors occurred
> 
> $ git lfs fetch remote\_3 —all
> Scanning for all objects ever referenced...
> ✔ 5 objects found
> Fetching objects...
> Git LFS: (3 of 3 files) 228.41 MB / 228.41 MB
> \`\`\`
> 
> It’s worth mentioning that on a large git repo (around 100+ remotes) the \`Scanning for all objects ever referenced\` phase takes about a minute, so updating the entire repository takes a very long time.
> 
> The end result is still good, as the lfs objects are cached successfully.

> <https://github.com/git-lfs/git-lfs/issues/436>
>
> 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?

and

> <https://github.com/git-lfs/git-lfs/issues/1759>
>
> I have remote named as \*\*remoteA\*\*. Also I don't have \*\*origin\*\* remote at all.
> …
> When i try to make a new branch for \*\*remoteA\*\* it fails with:
> \`\`\`
> $ git branch
> \* master 2367cfe \[remoteA/master\] \<commitmsg\>
> 
> $ git co -b x-dev remoteA/x-dev
> Downloading \<file\> (104.67 KB)
> Error downloading object: \<file\> (780085882a3d0a264ff1fc80647a799f11625fd8ccdcdf8d03b96bfa2da7c9a4)
> 
> Errors logged to \<folder\>\\.git\\lfs\\objects\\logs\\20161212T123905.0284272.log
> Use \`git lfs logs last\` to view the log.
> error: external filter git-lfs smudge -- %f failed 2
> error: external filter git-lfs smudge -- %f failed
> fatal: \<file\>: smudge filter lfs failed
> 
> $ git lfs logs last
> git-lfs/1.5.3 (GitHub; windows amd64; go 1.7.4; git 23455e48)
> git version 2.9.2.windows.1
> 
> $ git-lfs.exe smudge -- \<file\>
> Error downloading object: \<file\> (780085882a3d0a264ff1fc80647a799f11625fd8ccdcdf8d03b96bfa2da7c9a4)
> 
> Smudge error: Error downloading 780085882a3d0a264ff1fc80647a799f11625fd8ccdcdf8d03b96bfa2da7c9a4: http: Post objects/batch: unsupported protocol scheme "": http: Post objects/batch: unsupported protocol scheme ""
> github.com/git-lfs/git-lfs/errors.newWrappedError
> C:/Go/src/github.com/git-lfs/git-lfs/errors/types.go:166
> github.com/git-lfs/git-lfs/errors.NewSmudgeError
> C:/Go/src/github.com/git-lfs/git-lfs/errors/types.go:252
> github.com/git-lfs/git-lfs/lfs.PointerSmudge
> C:/Go/src/github.com/git-lfs/git-lfs/lfs/pointer\_smudge.go:70
> github.com/git-lfs/git-lfs/lfs.(\*Pointer).Smudge
> C:/Go/src/github.com/git-lfs/git-lfs/lfs/pointer.go:65
> github.com/git-lfs/git-lfs/commands.smudge
> C:/Go/src/github.com/git-lfs/git-lfs/commands/command\_smudge.go:51
> github.com/git-lfs/git-lfs/commands.smudgeCommand
> C:/Go/src/github.com/git-lfs/git-lfs/commands/command\_smudge.go:110
> github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra.(\*Command).execute
> C:/Go/src/github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra/command.go:477
> github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra.(\*Command).Execute
> C:/Go/src/github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra/command.go:551
> github.com/git-lfs/git-lfs/commands.Run
> C:/Go/src/github.com/git-lfs/git-lfs/commands/run.go:66
> main.main
> C:/Go/src/github.com/git-lfs/git-lfs/git-lfs.go:33
> runtime.main
> C:/Go/src/runtime/proc.go:183
> runtime.goexit
> C:/Go/src/runtime/asm\_amd64.s:2086
> 
> ENV:
> LocalWorkingDir=\<dir1\>
> LocalGitDir=\<dir2\>
> LocalGitStorageDir=\<dir3\>
> LocalMediaDir=\<dir4\>
> LocalReferenceDir=
> TempDir=\<dir5\>
> ConcurrentTransfers=3
> TusTransfers=false
> BasicTransfersOnly=false
> BatchTransfer=true
> SkipDownloadErrors=false
> FetchRecentAlways=false
> FetchRecentRefsDays=7
> FetchRecentCommitsDays=0
> FetchRecentRefsIncludeRemotes=true
> PruneOffsetDays=3
> PruneVerifyRemoteAlways=false
> PruneRemoteName=local
> AccessDownload=none
> AccessUpload=none
> DownloadTransfers=basic
> UploadTransfers=basic
> GIT\_DIR=.git
> GIT\_LFS\_PATH=C:\\Program Files\\Git\\bin
> GIT\_PREFIX=
> \`\`\`
> 
> And if I have \*\*origin\*\* remote it tries to fetch lfs objects from there.
> So, where and how I should setup LFS for each remote in repo?
> 
> Another example:
> 1. Clone repository with LFS files
> 2. Rename remote \*\*origin\*\* to \*\*smth\*\*
> 3. Try to make a new branch from renamed remote

the last of which contains a workaround.

---

<div class="post-metadata">

**Author:** ![firat](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@firat](https://renku.discourse.group/u/firat)\
**Post date:** [2 June 2021 07:27 UTC](https://renku.discourse.group/t/multiple-remote-with-git-lfs/344/7 "2021-06-02T07:27:23Z")

</div>

Hi @ralf.grubenmann,

When I first came across the last issue you referenced, I thought that cannot be it, because it didn’t seem to do anything at first. I tried again on a clean clone of the other repo, trying to git lfs pull from renkulab this time.  
1st attempt, same error (for a different git LFS object, obviously). Git checked out git files, but lfs failed, so I was still on the old branch from other remote with all the different files.

```auto
git stash save

```

and one more attempt, then it worked! I don’t know why git LFS tried to download objects the first time I checked out a branch from renkulab even though I disabled it

```auto
git lfs install --skip-smudge --local

```

Regardless, it now seems to work, thanks!

* * *

For future reference, exact steps are the following. For the setting where I am on remoteA and I want to fetch git LFS from branch branchB from remoteB:

```auto
git lfs install --skip-smudge --local
git checkout -b branchBfromremoteB remoteB/branchB
git lfs pull remoteB

```

If second step fails, `git stash save`, and repeat again… 🙂

Firat
