One of the repositories I am working with has invalid characters for windows within a filename. Specifically, the files have ':' (colon) characters in the name. I do not know how the files were named as such, and cannot have those files removed from the repository, as they are needed by the team that owns the repository.
We are able to work within the repository through Git's web interface, but the given files prevent us from successfully cloning the repository locally. When cloning the repository, these files cause an error because of the invalid name, and remain in the index. Locally, git recognizes the files as "deleted" because they cannot exist locally, and I am unable to revert or stash the perceived changes.
I have tried adding a pattern to my global .gitignore file to exclude all files with a colon in the name (:), but that does not appear to affect the checkout process. Is there a method I could use to have these files ignored on checkout without removing them from the repository?
CodePudding user response:
The best way to solve this problem is to work with the repository under the Windows Subsystem for Linux (WSL). For file paths stored within the WSL pseudo-disk, it's possible to use arbitrary non-NUL bytes in path names, just like on Linux. If using macOS is a possibility, that would also work.
Your attempt at ignoring the files with .gitignore
doesn't work because it has no effect on already tracked files, and Git does not provide a way to ignore changes to tracked files.
You could try sparse checkout, but note that the non-cone mode is deprecated. That means that you'd want to disable checking out an entire directory that contains the files if they're all in one directory. Sparse checkout can still work in non-cone mode (in which case your patterns would look like *
and !*:*
), but it has known performance problems and there isn't really a plan to address them.