Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LFS files aren't reported in git lfs ls-files command #5119

Open
SalmaFarghaly opened this issue Sep 20, 2022 · 5 comments
Open

LFS files aren't reported in git lfs ls-files command #5119

SalmaFarghaly opened this issue Sep 20, 2022 · 5 comments
Labels

Comments

@SalmaFarghaly
Copy link

I was applying GIT-LFS on a new repo and I am having a folder that contains bin files and I have done the following :

  1. git init
  2. git lfs track "*.txt"
  3. git add .gitattributes
  4. git add .
  5. git commit --m "Add Files"
  6. git lfs ls-files -> doesn't output the txt files in the repo

I am expecting 'git lfs ls-files' to output the txt files in the folder.

@bk2204
Copy link
Member

bk2204 commented Sep 20, 2022

Hey,

Thanks for the report. My guess is that we don't handle the root commit correctly here, which is why this occurs. I'll mark it as a bug and see if we can fix it.

@bk2204 bk2204 added the bug label Sep 20, 2022
@SalmaFarghaly
Copy link
Author

SalmaFarghaly commented Sep 20, 2022

Hey @bk2204 ,

Thank you for responding. I have done a further investigation that might help. I have tried to create a txt file through a git bash to see if it will be also reported as LFS file or not. I have done the following steps:

  1. cd into an empty folder
  2. create a file 't1.txt'
  3. open git bash and run the following :
    1- echo dummy > t2.txt --> that will create t2.txt file in folder
    2- git init
    3- git lfs track '*.txt'
    5- git add .gitattributes
    6- git add.
    7- git commit --m "commit"
    8- git lfs ls-files --> I can see only t2.txt is reported which was created through the GIT bash

Do u think there is any workaround I can do for now to avoid that problem without the need of creating files through git bash?

@bk2204
Copy link
Member

bk2204 commented Sep 20, 2022

Ah, I see what the issue is. If the file is empty, then it's not reported. I don't think this has anything to do with Git Bash because I can also reproduce it on Linux as well.

@SalmaFarghaly
Copy link
Author

Ah, Okay Thank u for that. Creating the file with content has fixed my problem.
I also need to apply the lockable attribute to the non-empty file to convert it to read-only but that is not happening. I have tried the same steps above but added git lfs track '*.txt' --lockable :

cd into an empty dir
create non-empty t1.txt file
git init
git lfs track "*.txt"
git lfs track "*.txt" --lockable
git add .gitattributes
git add .
git commit --m "Add Files"
git check -attr lockable t1.txt -> shows that the lockable attr is set. But when I open the file on disk. I can edit it. its permission has not changed to read-only.

@bk2204
Copy link
Member

bk2204 commented Sep 20, 2022

Hey,

Setting --lockable for a file doesn't change the permissions. That's only the case when you run git checkout (or git clone) for a repository, or use git lfs checkout or git lfs pull. If you want that file to have read-only permissions before you change the branch, then you need to set them in the working tree.

This is because you don't have to use git lfs track; you could simply modify .gitattributes directly. It would be pretty inefficient to update the files on every commit when there's no expectation that the files have in fact changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants