Search code examples
macosgitatlassian-sourcetree

Remove weird 'Iconr' file from the repository


In my git repository I've got a weird file in the staging area that's refusing to be reverted, removed, committed - basically I can't make it go away..

The file must be some ancient OS 9 file sitting there in the folder for years.

Couple days ago I've removed the file in the file system so now git is tracking the deletion of Iconr.

However, it's stuck there.

The error I'm getting via SourceTree (my git UI client) is

fatal: pathspec 'folder/Iconr' did not match any files

Any idea how to make git completely forget about that file?


Solution

  • It is best to revert to the command line in order to have a more precise error message.

    There you can try a git add -u, followed by a git commit, in order to register the deletion of that file in the repo.
    See "git status says file is deleted but git rm says error: pathspec '…' did not match any files" as an example.

    You can also preview what a git clean would give: git clean -d -x -n (as explained in "Why is there no “pathspec” when I try to remove a folder in Git?")

    The other issue is when that file isn't tracked at all in your current branch, but is tracked in another branch. See that answer to check if that is the case.