3

We are looking to move a specific directory from one git repository to another. I found these instructions, which went well until the point of the pull from the remote branch; it appears that having files on both sides that are tracked by git-lfs complicates the process somewhat.

I tried this both directly between my local clones, as well as doing the filter-branch on a branch and pushing it to the main server (VSTS). In both cases the smudge filter failed, saying it couldn't find the LFS-tracked file; with the VSTS remote the error logged is a 404.

I'd like to keep these files as LFS tracked in the destination, whether the move is done using the local clones direct or involves the server. Are there any additional commands/switches or preparation steps that will allow this?

nj2237
  • 1,220
  • 3
  • 21
  • 25
  • Apologies for the title; I'd replaced my search terms with "Move git directory from one LFS-enabled repo to another (also LFS)" but it appears the browser on this device reverted the change, and now I can't seem to edit it... –  Mar 18 '18 at 16:05

4 Answers4

4

According to repository clone times-out lfs files cannot be retrieved #1181

In both cases the smudge filter failed, saying it couldn't find the LFS-tracked file; with the VSTS remote the error logged is a 404.

It means that the files do not exist on the server. You can try to find a local clone of that repository that has it, and run git lfs push REMOTE_NAME --all.

And you may need to execute git lfs fetch --all to download all LFS-tracked files before you push them to your new Git repository.

piet.t
  • 11,718
  • 21
  • 43
  • 52
S.Y. Wang
  • 224
  • 1
  • 8
  • The key here was `git lfs fetch --all`. –  Mar 19 '18 at 15:08
  • Is this what you need? – S.Y. Wang Mar 19 '18 at 15:15
  • More detail in separate answer. –  Mar 19 '18 at 15:21
  • Related step-to-step answer can be found [here](https://stackoverflow.com/a/62911723/2538363). But essentially - as described in this answer - executing `git lfs push` to the destination repo fixes errors for missing `lfs` files that can occur during the `pull --allow-unrelated-histories` step. `lfs` files are handled separately and should be handled separately also during a migration. – BaCaRoZzo Dec 14 '21 at 07:39
  • 1
    This was the breadcrumb that helped me move a repo with LFS between two workspaces on BitBucket, which is not currently supported via their Transfer Repository function. I did a `git clone `, then cd into it, then `git lfs fetch --all`, then `git remote -v` to confirm source location, then `git remote set-url origin `, then `git ls-remote` to confirm, then `git push origin --all`, then `git lfs push origin --all`. – djdanlib Feb 10 '22 at 22:14
2

(Upvoted the other answer for the hint in the right direction, though my newbie rep won't have it show.)

The key here seems to have been git lfs fetch --all before branching off and running filter-branch, move and commit as described in the article. It looks like LFS isn't intended to work between local clones; reversing the procedure so as to push to the destination clone also resulted in an error, but it did work when pushing to the remote server for the destination repo.

From there, a fetch into the destination clone and merge with --allow-unrelated-histories looks to have given us what we were after.

0

for my the easiest way was to fork the repository (it means on the server side)

YaP
  • 339
  • 3
  • 13
0

Turning @djdanlib 's comment into an answer (with some clarification) as this was the most helpful answer for me and my team during a transition from GitHub to ADO.

  • git clone <OLDURL> (if you don't already have it locally)
  • git remote -v (check that you are pointed to the old repo)
  • git lfs fetch --all (forces the download of all the LFS files)
  • git remote set-url origin <NEWURL> (you are now pointing to your new repo)
  • git remote -v or git ls-remote (double-check you are pointing to the new URL)
  • git push origin --all (pushes all branches to the repo)
  • git lfs push origin --all (pushes all LFS files to the repo)
loganjones16
  • 492
  • 4
  • 19