Git repo: ignore any sub-directories that have their own git repos

25 Views Asked by At
  • I want to track *.md files recursively under my main ~/Documents dir. And nothing else.
  • However there's some subdirs under there that are their own projects with their own .git repos
    • So those dirs can be ignored entirely, I don't need to track their *.md files in my main ~/Documents/.git repo
    • But I still want to leave those subdirs where they are

In my ~/Documents/.gitignore file I have:

*
!*/
!*.md

When I try running git add -A ... it fails with an error on the first subdir it comes across that has its own .git repo:

error: 'some-subdir-project-that-can-be-ignored/' does not have a commit checked out

How can I get git to just skip any of those subdirs, without needing to specifically specify every one of them to be ignored by name (either now, or any others that appear in there later on).

0

There are 0 best solutions below