1

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?

Libin Varghese
  • 1,506
  • 13
  • 19

1 Answers1

0
  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
Libin Varghese
  • 1,506
  • 13
  • 19
  • 2
    You can also add this one-liner to your git config file: `awk 'FNR==NR {a[$0]++; next} !a[$0]' <(git annex find) <(git ls-files)` and if the number files is really large, see [this question](https://stackoverflow.com/questions/18204904/fast-way-of-finding-lines-in-one-file-that-are-not-in-another) on fast alternatives to that awk script. – Nei Neto Aug 26 '20 at 16:56