gitgit-annex

List all files in git repo not added by `git annex add`


Is there a way to list all files I added via git add (ref 1) and not by git annex add (ref 2)?

mkdir myrepo
cd myrepo
git init .
mkdir foo
dd if=/dev/random of=foo/bar.ext count=1024 bs=1024
git add foo   # <----- ref 1   
git commit -m "add foo"
git annex init "listing"
mkdir baz
dd if=/dev/random of=baz/abc.ext count=1024 bs=1024
dd if=/dev/random of=baz/efg.ext count=2024 bs=1024
dd if=/dev/random of=baz/xyz.ext count=512 bs=1024
git annex add baz    # <---- ref 2
git commit -m "add baz"

So when I run git <some command> it should show something like

foo/bar.ext

One of the solutions I used is https://stackoverflow.com/a/61680771/7274758 . But I am wondering if there is any better way?


Solution

    1. Use ls-files to list all files in repo.
    2. Use annex find to list all files in annex.
    3. Find the unique entries from the above results
    git ls-files > ~/tmp/ls-files.list
    git annex find > ~/tmp/annex-find.list
    awk 'FNR==NR {a[$0]++; next} !a[$0]' ~/tmp/annex-find.list ~/tmp/ls-files.list