jagjordi
jagjordi

Reputation: 103

gitignore everything but certain extencions and also directories

I want to be able to make Git ignore everything but certain types of extensions.
This is my current .gitignore file:

# ignore everything
*
# but desired files
!*.vhd
!*.tcl
!*.py
!*.cpp
!*.c
!*.tex
!*.asm
!*.qpf

The problem is that now Git also ignores patterns like this some/directory/somefile.vhd

If I add !*/now directories starting with dot are not ignored.

How can I prevent that from happening?

I also tried adding two asterisks but the result was the same.

Upvotes: 0

Views: 36

Answers (1)

Dietrich Epp
Dietrich Epp

Reputation: 213837

If the directory is ignored, all files inside will be ignored too. You can exclude the directories with the following:

*
!*/
.*/
!*.vhd
!*.tcl

Etc. Including the directories this way just means that those directories will be checked for non-ignored files. Directories are not actually included in Git.

Upvotes: 1

Related Questions