Tuesday, October 26, 2021

[SOLVED] Add previously ignored directory to Git repository

Issue

My .gitignore file looks like:

html/
cache/
resources/
# Temp files often created by editors
*.~

I know wish to start tracking a specific directory in html, so I add `!html/support/

html/
cache/
resources/
# Temp files often created by editors
*.~
# Track support
!html/support/

After doing so, however, Git still doesn't seem to track html/support/ and all its children.

How do I add a previously ignored directory to Git repository?


Solution

Not ignoring doesn't mean tracking.

Just use

git add html/support/

at the root of your git repository.

If the file is still ignored, though, you can use git add -f to force adding it (this will not modify the .gitignore file, just allow one little exception) :

git add -f html/support/


Answered By - blue112