A file was added to a project's git repository at work with an illegal filename (under Windows). The filename had an invalid character in the extension: a question mark.
When I tried fetching/rebasing with TortoiseGit an error message popped up which contained "error: unable to create file /path/to/file.ext? (Invalid argument)". Confused, I looked at the upstream's log and, effectively, a file with an invalid character in the extension had been added.
To solve the issue I dropped down to git's command line:
$ git fetch $ git rebase First, rewinding head to replay your work on top of it... error: unable to create file Path/file.ext? (Invalid argument) Applying: My local commit.
The problematic file wasn't created in my working directory, but the rebase worked correctly. All that was needed was to delete the file with the invalid character in the extension from git's index (as it wasn't in my working directory), commit and push so we could continue working.
$ git rm --cached Path/file.ext? rm 'Path/file.ext?' $ git commit -m "Delete problematic file with invalid character." [develop bdf3b40] Delete problematic file with invalid character. 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Path/file.ext?
Then I pushed and all was right again. The important part was to remove the file from git's index, leaving the working tree alone. Attempting to just git rm the file would result in
$git rm Path/file.ext? fatal: pathspec 'Path/file.ext?' did not match any files
I was able to do this so quickly thanks to an article on git reset I'd just read the other day that explains git's three different trees.