Add previously ignored git files. git add -f not working

1.7k views Asked by At

I used

git status --ignored 

To check which files were ignored as follows :

 git status --ignored
# On branch SIT
# Ignored files:
#   (use "git add -f <file>..." to include in what will be committed)
#
#       web/sites/default/files/

So, that's fine. But when I use :

git add -f web/sites/default/files/

And then use "git status --ignored" again it shows the same file. Even after adding these to a commit.

1

There are 1 answers

0
thinkmassive On

You probably need to add a file under that directory, rather than adding the directory on its own. To add all contents of that directory:

git add -f web/sites/default/files/*

I had a similar issue, although my issue was caused by a git update-index --assume-unchanged command that I had issued earlier without fully understanding it. In case someone arrives here for a similar reason, I solved my issue by executing:

git update-index --no-assume-unchanged <myfile>
git add <myfile>

Refer to the git-update-index docs for more details.