Search code examples
git-lfs

Fix git-lfs user error


We have a git-lfs enabled repository in gitlab, it works fine. It nicely separates pdf, movies, and other things we don't want to version manage.

There was a user error where somebody cloned the repository on a system that did not have git-lfs support enabled. That person added a pdf file to git and pushed back to server.

Then another user fetches that branch on a system that does have git-lfs, and tries to check it out:

   $ git checkout pj-guide_47_mac_R_setup
   Switched to branch 'pj-guide_47_mac_R_setup'
   Your branch is behind 'origin/pj-guide_47_mac_R_setup' by 14 commits, and can be fast-forwarded.
    (use "git pull" to update your local branch)
    Encountered 1 file(s) that should have been pointers, but weren't:
        47.mac_R_setup/47.mac_R_setup-slides.pdf 

What is the most direct route on the system that does have git-lfs properly configured to fix that pdf file? According to https://github.com/git-lfs/git-lfs/issues/1726 there is a usage of git lfs merge import released with git-lfs 2.3.0, but I'm not able to understand how to use it.


Solution

  • I asked similar question about a slightly different use case in the git-lfs issue tracker. git-lfs issue 2845

    @larsxschneider gave this answer:

    "The easiest way is this:

    git rm --cached <PROBLEM FILE>
    git add --force <PROBLEM FILE>
    git commit -m "Move files properly to GitLFS"
    

    This would copy the content of your PDF files from pure Git to Git LFS. The drawback of this method is that the current version of your content stays in pure Git's history (which might increase the size of your repo). Every future update of the content will be only in Git LFS though."

    That author suggests I avoid "git lfs migrate import" except in case of emergency. The alteration of history may wreak havoc if several users are involved."

    Lars Schnieder also mentions a new Youtube presentation on this. "GitLFS- How to handle large files in Git - Lars Schneider - FOSSASIA Summit 2017"