Edward
Edward

Reputation: 967

git negation of excluding hidden directory with hidden files

I manage config files in my home directory with git. Here is the simplified content of the .gitignore file in my home directory.

*
!.bashrc
!.bash_aliases
!.gitignore

I created a new directory in my home directory .bashrc_includes with several files:

.bashrc_includes/
├── .bashrc_android
├── .bashrc_asdf
└── .bashrc_sdkman

I would like to add this directory with all the files inside it to the repository. I tried to add !.bashrc_includes/* to my .gitignore, but look like it is still ignored by git.

What is the right way to do it?

Upvotes: 0

Views: 98

Answers (1)

Samuel Dion-Girardeau
Samuel Dion-Girardeau

Reputation: 3180

Adding !.bashrc_includes/* will exclude the files from the ignored files, but the directory itself is still ignored!

The following .gitignore allows you to exclude the directory and the files inside from the ignored files:

*
!.bashrc
!.bashrc_includes/*
!.bashrc_includes/
!.bash_aliases
!.gitignore

You can find some more in-depth explanations in this question: .gitignore exclude folder but include specific subfolder.

Upvotes: 1

Related Questions