Add Files to Git Which are Ignored via .gitignore

In a recent project, I needed to add a file which was in a folder that was ignored using the .gitignore file.

Now I could edit the .gitignore file, commit the file, then edit the .gitignore again. But this seemed like a cumbersome way to do it.

Luckily I found that the git-add command has a --force option.

-f --force
Allow adding otherwise ignored files.

For example:

git add --force ignored-file.php

Enjoy.

Leave a Reply

Your email address will not be published. Required fields are marked *