'Moving file under git lfs from one directory to another within the same repository

I have a file that is under git lfs control that I want to move from one directory to another within the same git repository. However, git mv foo/bar baz/ works for regular files, but does not bring along the LFS state, so I cannot use that.

I.e., I was thinking along the lines of:

  1. git mv foo/biglfs.file bar/
  2. git lfs track *.file
  3. git add bar/.gitattributes
  4. git commit

But I don’t think that properly updates the LFS file pointers, and I think the first statement will actually add biglfs.file to the repo directly, which isn't desirable.

I think I have to manually remove the file from under git lfs control, move the file, and then re-add it. But that strikes me as a lot of work, so surely there's an easy and direct way to do this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source