Solutions

Ignoring Nested Files

As with most programming issues, there are a few ways that you could solve this. If you only want to ignore the contents of results/plots, you can change your .gitignore to ignore only the /plots/ subfolder by adding the following line to your .gitignore:

results/plots/

If, instead, you want to ignore everything in /results/, but wanted to track resul./data, then you can add results/ to your .gitignore and create an exception for the resul./data/ folder. The next challenge will cover this type of solution.

Sometimes the ** pattern comes in handy, too, which matches multiple directory levels. E.g. **/results/plots/* would make git ignore the results/plots directory in any directory.

Including Specific Files

You would add the following two lines to your .gitignore:

*.data           # ignore all data files
!final.data      # except final.data

The exclamation point operator will include a previously excluded entry.

Ignoring all data Files in a Directory

Appending

resul./data/position/gps/*.data

will match every file in resul./data/position/gps that ends with .data. The file resul./data/position/gps/info.txt will not be ignored.

Log Files

  1. append either log_* or log* as a new entry in your .gitignore
  2. track log_01 using git add -f log_01