I'm trying to use version control in my music folder to track how I sort it and when I add/delete music. I only need the metadata and not the contents in the repo.

To achieve this, I'm using tree to maintain two text files that are in .list in the root directory for the repo.

This is the script run by cron every 15 minutes:

cd /home/user/folder/ && tree -faRn -o /home/user/folder/.list/1
cd /home/user/folder/ && tree -faRhupsDn --du -o /home/user/folder/.list/2
git -C /home/user/folder add .list
git -C /home/user/folder commit -m $a 

It's also monitoring the .git folder (!) and this means that it's committing everytime the script runs. Should I add .git to a gitignore? Why is it watching the .git folder anyway? is it because my directory is named .list? Do I need to double quote it? .list isn't a git repo.

tig output

Thanks, kusalananda!

Here's the modified (and working!) script:

cd /home/user/folder/ && tree -faRn -I '.git|.list' -o /home/user/folder/.list/1
cd /home/user/folder/ && tree -faRhupsDn -I '.git|.list' --du -o /home/user/folder/.list/2
git -C /home/user/folder add .list
git -C /home/user/folder commit -m $a 

It is tree that looks into the .git directory.

You will want to tell tree to ignore the .git directory. On the Ubuntu machine that I have access to, this is done with

tree -I '.git' ...other options...

You may also want to have it ignore the .list folder.

  • How did I miss that? – Patrick Bateman Feb 17 '18 at 15:02
  • @PatrickBateman Head-too-full-induced selective blindness. Happens to me on the best of days. Hmm... "Inattentional blindness" is a thing it seems. – Kusalananda Feb 17 '18 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.