0

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?

Edward
  • 917
  • 1
  • 9
  • 18
  • Possible duplicate of [.gitignore exclude folder but include specific subfolder](https://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder) – phd Jun 18 '18 at 14:57

1 Answers1

1

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.

Samuel Dion-Girardeau
  • 2,790
  • 1
  • 29
  • 37