My logic is still not very good, it may be a little convoluted. But look carefully will definitely harvest!
When I was an intern, I found that I could not find the dependent file when I was building the server after writing the code, but it was normal in the local Build. After checking for a long time, it was clear that there was no problem, but the path error was reported on the server, which made me very headache.
Finally, I found that there are two folders with the same name on the server (case different) after helping Debug. Such as: ABC and ABC, because the server is on a Linux system, which is case sensitive, so both files can exist at the same time, but after pulling to the local, (because Windows and macOS (default) and Git (default) are case insensitive), the ABC folder will not be visible locally and will be merged into the ABC folder.
Because all files in the local ABC folder are in the ABC folder, all dependency paths in the code are.. /ABC/.. At this time, it is no problem to run locally.
But on the server, some of the dependent files actually existabc
In the. Because paths are all pointingABC
And theABC
These files are not in the file (file inabc
In), the path error will be reported.
How did such a mistake come about?
I was very curious about this problem, so I looked at the commit record of the folder at the time, and found that there were two people working together to develop a task, so they agreed on the folder name together, but there was a problem because the case of the name was not specified.
For example, A creates ABC and then the dependency path in the code is.. /ABC/.. B creates ABC with a dependency path of.. /abc/.. . Since the folders will exist after being uploaded to the server and will not be merged, there will be no path error for the situation at that time. So, this hole is created.
This error causes problems
This pit for later developers to say a big pit, no, should be said to be giant pit, sinkhole!
* When the code is pulled to the local location, the two folders will be merged into a single folder, such as ABC. /abc/.. Debug will find that there is no dependency on this function. /abc/.. No wonder there will be problems, quickly change to.. /ABC/.. Well, at this point the code is OK and ready to run. * * but! ** When the code was pushed to the server again, the problem arose because the code that relied on the ABC folder was changed to.. /ABC/.. Ah, but the file is still in ABC, so the code on the server is exploding again.
This time to take over the heart of the code: WTF?? Just let me die.
Solution
Delete one of the two folders on the server and re-upload the code to make sure there is only one folder.
How to avoid this problem:
- Define specifications for file names, such as using humps, all lowercase, etc
- When creating folders with two branches, make sure that the name case is not wrong, or you will merge them into two folders
expand
Git is case insensitive by default
Based on the above analysis, I think there is a reason to be compatible with Windows and macOS, which are case-insensitive by default.
Even though Git supports case sensitivity, you can have two different case folders with the same name, but Windows and macOS can’t display them.