Ivan ZugecContactContact me
All posts

Add Files to Git Which are Ignored via .gitignore

Web Development

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.

Hiring, or have a project in mind?

Get in touch and tell me about the role or what you're building.

Contact me