>_ IzzyLab

Hands-on task

This task is step 17 of the course “Everyday Git”

Figure out which rule ignores the file

medium~7 min

In /root/repo the file logs/app.log isn't under version control — the .gitignore rules ignore it. There are several rules, they live in more than one file, and more than one matches this path. Figure out which exact rule (pattern) ends up ignoring logs/app.log, and write that pattern into the file /root/answer.txt.

What you'll practise:
  • gitignore
  • git check-ignore
  • rule priority
  • ignore patterns
  • debugging ignore

Topic breakdown

When a path matches several .gitignore rules, the winner is not the first but the last matching rule — eyeballing it is unreliable. The exact answer is given by git check-ignore: with the verbose output flag (-v) it prints the source, line number and the very pattern that actually took effect. From that line all that's left is to cut out the pattern field with the usual text tools like awk, cut or sed.

What's checked

  1. answer written
  2. pattern is correct

What it looks like