How to un-ignore a file with git?

I added a file by mistake to .git/info/exclude I removed it from the .git/info/exclude but I can't get git to track it again

when I try to checkout the file I get a

error: pathspec [filename] did not match any file(s) known to git.

1 answer

  • answered 2018-01-14 11:31 MAhipal Singh

    try git update-index with assume-unchanged

    git update-index --assume-unchanged <file>
    git update-index --no-assume-unchanged <file>
    

    the files are always assumed unchanged. want to track changes in these files again, use --no-assume-unchanged.

    To get a list of files that are assume-unchanged run this:

    git ls-files -v | grep '^[a-z]'
    
    • git ls-files -v will print all files with their status.
    • grep '^[a-z]' will filter files and select only assume unchanged

    to undo all assume-unchanged that we have made then use : git update-index --really-refresh

    more about git-update-index