Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List files not tracked by Git LFS

Tags:

git

git-lfs

I'm initializing a new Git repo with a huge pile of files. The repo is using Git LFS. I want to ensure that I've told LFS to track all files that should be handled, before I make my first commit.

I see that git lfs ls-files will list all the files that ARE tracked by LFS. However, (a) I want the opposite: all files in the repo that aren't tracked by LFS (and are in .gitignore), and (b) this command only works after you have committed files.

Does anyone have some git-fu or Ubuntu-fu to list all the files in the repo that aren't ignored and aren't matched by the track patterns in the various .gitattribute files Git LFS uses?


The closest I've come is this command that lists files in the repo over 100kB, and then manually scanning all the files and hope that I've them covered by a tracking pattern.

find . -type f -exec du -Sha -t 100000 {} +
like image 470
Phrogz Avatar asked Mar 22 '17 22:03

Phrogz


People also ask

How do I view LFS files in GitKraken?

Viewing Git LFS Files All files tracked by Git LFS will be marked with the LFS icon in the right panel of GitKraken’s central graph. When you click to view the Git diff of such a file, you will see the SHA reference instead of your large file.

Can I use Git LFS on a file that is already committed?

Using Git LFS on a file that is already being track without it requires an extra step. I ran into an issue where I wanted to use Git Large File Storage on a file I had already committed to a repository without using git-lfs. Let's say my file is some beefy design file that I saved to design/mockups.sketch.

How are changes to audio and video files tracked in Git?

When working with repositories that contain audio, video, or image files (aka binary files), any changes made to those files are not tracked through Git in the same way that non-binary files are tracked. While Git does a great job of tracking change sets in text files, changes made to binary files are tracked as an additional copy of the file.


1 Answers

Even though the question concerns files that have not been commited, let me suggest a solution to list the files tracked by git but not git-lfs after commit, which you can do by concatenating the list of files tracked by git (git ls-files) with those tracked by git-lfs (git lfs ls-files | cut -d' ' -f3-) and then only take the files that are unique in this list:

{ git ls-files && git lfs ls-files | cut -d' ' -f3-; } | sort | uniq -u

After which you could edit your commit (git rm --cached and git commit --amend) if you notice a file that has sneaked in...

At the pre-commit stage, proceeding by watching the untracked files list and successively using git lfs track and git add should be quite safe.

like image 54
François Avatar answered Nov 09 '22 21:11

François