Colon in a git file name. Windows developers alarm?
Yesterday a coworker running Linux on his laptop pushed to our master a set of files with a colon
: in their names.
This is a legal file name in Unix world, but others running Windows could not pull anymore. Eclipse cancels the pull as the file name is valid. Git from console pulls the repository but does not allocate those files because of their illegal file name, so I end up with a working copy with missing files.
Before answering “switch to Linux” or “Linux is better than…” please understand that this is indeed an error as our software is normally deployed to both Windows and Linux servers, so including an illegally named file in a war package will result in a crash.
Here are my questions:
- Is it possible in Git to restrict file naming? For example, SVN warns the committer when two files with different casing coexist or a file is renamed in its casing (e.g.
MyClass.cs). I would like to enforce Windows-style names in files, as Windows is strictly more restrictive than Unix. I don’t know about any legal file name that is illegal in Unix world
- Is it dangerous to keep such commit in history? I have successfully asked the committer to revert his change, reset my working copy to a few revisions before that guilty commit, and then pulled. However nobody using Windows will ever be able to pull that revision (not a problem) or probably rebase it interactively in a branch
Yes, I understand it was a mistake to let him push directly to master, as we could easily isolate and obliterate che change if it was in a branch.
Since we have a bunch of active branches that are behind the master and need to be merge-aligned before PR, and need to be merged, I am wondering if it could be a good idea to rebase the master onto itself, force push and let all developers learn their lessons.
As final note, we use
Bitbucket Server running on a Linux host and can perform merging using pull requests
One Solution collect form web for “Colon in a git file name. Windows developers alarm?”
You could install some git hooks (doing appropriate checks), notably a git precommit hook (at least for Linux users), or a prepush hook.
Of course, that requires some cooperation (and convincing people to use it).