I am trying to use git in a Joomla project and the strategy I was thinking of was to ignore everything except a selected folders/subfolders. I tried some of the suggested methods from this answer but to no avail:

Here is what I am trying to put in the .gitignore file:

# ignore everything
# except mod_mymodule and com_mycomponent

Running git status on this, git does not asks me to add any untracked files even though none of the files within the folder are currently in the repo. Am I doing something wrong or is it just not possible?

  • 1
    Never done it before but you could try to add a trailing / to your folders like !modules/mod_mymodule/ and so on. Or maybe with /*. At the moment I think you are just "unignoring" the folder itself, not its contents.
    – fruppel
    Dec 4 '15 at 11:57

The answer is based on the answer(s) in the link I had in the question and what fruppel suggested in the comment but since I couldn't mark that as answer; I am answering it myself. Here is what I did:

# Exclude everything
# Include components directory and everything underneath
# Exclude all components in component directory
# Include custom component that needs to be added to git

After this running 'git status' shows the components folder can be tracked which is not as helpful as it can be confusing since it sort of implies the whole thing is being added. That is why another command I ran gave 'git status --untracked=all' a better detail. Hope it helps someone.


Hello sifu,

This is pure .gitgnore file for Joomla!. It contains all files and folders that core Joomla! installation contains and will remove tracking of all joomla! files comes after installation.


Let me know if it solves your problem.


  • Thanks for pointing that out and I was aware of that but it was not what I was looking. If I install custom components, I will have to constantly keep updating that list which is why I decided to go against it.
    – sifu
    Dec 6 '15 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.