Search code examples
gitgithubgit-lfs

How can we see the reference file inside our repo after adding the file with git lfs?


I have pushed a file using git-lfs in github. After pushing it, I can only see .gitattribute file changed under my commit in github like this:

file_name filter=lfs diff=lfs merge=lfs -text 

There are couple of questions I want to ask:

  1. Is .gitattribute file supposed to be changed only? Git lfs stores the reference of the file inside our repo. That reference file should be added in our repo right? Why can't I see that reference file under my commit in github?

  2. Actual file is pushed in a different server. From where exactly can we view it?

  3. Now when my branch gets merged with master branch, can other team members be able to access that file simply by adding git pull origin master? Obviously after they have properly configured git LFS.

  4. git lfs ls-files is not showing any files after adding it. Why is this so?

The commands I followed to push files with git lfs are:

1.Install git LFS using this command:

sudo apt get install git-lfs
  1. Initialize our repository with git-lfs using following command:

    git lfs install

  2. Track the files we want to add using this command:

    git lfs track filename

  3. Make sure .gitattributes is tracked using following command:

    git add .gitattributes

  4. Remaining steps are same:

    git add file-name git commit -m "File added with git lfs" git push origin branch-name


Solution

    1. The .gitattributes should change to reflect that files with this pattern will be handled by LFS, but it should not be the only thing that has happened. The file itself should also be added and show up as modified, because the pointer file is updated every time you change a binary tracked by LFS.
    2. The actual binary is stored elsewhere, each git hosting provider can choose where to store these files. GitHub puts these files in a cloud storage provider's blob storage. But the UI will list the file and handle the redirects on the server. Git-lfs will handle the download and replacement locally, if configured properly.
    3. In the current state your changed will not be merged, since the file isn't stored in LFS.
    4. That's the big question. So, which commands did you run and what did git status tell you?

    After successfully pushing your files to GitHub, they are marked as "LFS" when you try to view them:

    enter image description here

    enter image description here

    note a file that has previously been committed won't suddenly be converted to LFS by calling git lfs track. The next changes may. In some cases you may want to migrate the history of your repo over to LFS, this will rewrite history, change your commit-shas and will require force-push.