0

I want to stop git monitoring a directory so if I'm in that directory and type git status I get the message, fatal: not a git repository. Currently when I type git status, I get On branch master.

I've tried git rm -r --cached <filename> but get the message, fatal: not a git repository appears.

I'm quite new to this and so I'm not sure if I'm using the correct terminology here.

Thanks for any help.

Michael
  • 1
  • 1
  • 1
    Are you asking how to stop git tracking a subdirectory within a repository? – Calum Halpin Oct 18 '21 at 15:23
  • @CalumHalpin I doubt it is, but if the answer to your question is yes, then perhaps this question should be modified and re-opened. (And perhaps answered with, "you can't", I think.) – TTT Oct 18 '21 at 16:14

2 Answers2

1

Git is not tracking all the directories in your machine.

When you type git status in a directory, you are calling the program git and it simply return fatal: not a git repository because that directory is not a repository (it doesn't have .git directory). It is the normal behaviour. It's like run python with a file that hasn't a valid python language format.

Fran Moya
  • 89
  • 9
0

The premise of the question that git looks at all the directories is wrong.

Git commands such as git status work only in the directories where git has been initialized. Usually, you will find a folder like .git at the root of the directory where git is initialized.

E.g. lets say /usr/a/d1 where git is initialized. Then in the directory /usr/a/d1 and its subdirectory git status will not return fatal: not a git repository

Say /usr/a/d2 is a directory that is NOT initialized with git then in the directory /usr/a/d2 and in its subdirectory you will get fatal: not a git repository

Ajeet Ganga
  • 8,353
  • 10
  • 56
  • 79