1

I have created .gitignore file in the root of my git working directory, with the intention of ignoring any file with the .log extension, and ignoring any file that is contained in a directory called logs. The .gitignore file has these exact entries:

logs/
*.log

Now I would expect any files with the .log extension to be ignored by git, but when I add a file called test.log to the root of my working directory and run a git status, this file is showing up under the list of untracked files (I expected it to not be present because of the second line in my .gitignore file):

git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        test.log

Similarly if I add a test.log file into my /logs directory and run a git status, it doesn't show me the test.log file as an untracked change, but it still shows the creation of the logs directory as an untracked change (again in this instance I was expecting the entire directory to be ignored because of the first line in my .gitignore file):

git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        logs/

None of these changes have been committed to the repo yet, perhaps I'm misconfiguring the .gitignore file, or misunderstanding what it is supposed to do, any help would be appreciated.

0 Answers0