简体   繁体   中英

Why do I get “cannot create directory” when checkout a git remote branch windows?

I am on Windows 10 64Bit using git version 2.10.2.windows.1.

On MACOS we merged two branches into an existing branch. After merge the branch contains a folder with a white space at the end (" Jadise / "). I created a new branch based on the former merges on Bitbucket. Now, when I try to checkout my new branch under Windows I get this error:

fatal: cannot create directory at 'wp-content/plugins/orbitvu-sh/_orbitvu_presentations/Jadise /_orbitvu_resized_images'

Here is the way how I tried to checkout to the new remote branch

git fetch git checkout new-branch

It seems like this error is not refering to maximum path length in windows. As I put the repository also into the root of the volume and the error was thrown at the same point like being in the "original project folder" where I discovered this issue. I also don´t think that this error is related to access issues, as all the other directories have been created/updated without any issue.

As you might notice this is a plugin for wordpress and is maintained by a third party. This is the reason why I cannot simply change the directory name as it probably would stop working. At the same time I need the content of it in order to have a working build.

I cloned the project and switched to the branch in a debian virtual machine, and it worked without any issues. It seems like debian (or non git Windows / not sure if it is a windows issue or git issue) is capable of handling this directory name somehow. When I want to cd into it shows me "Jasmine\\ /" when I use tab to autocomplete.

Is this a windows issue or a git issue, and is there a way to solve it for Windows 10 64bit without renaming the folder of a 3rd party plugin?

Currently, git for windows does not support trailing spaces in filenames , and there is a reason for it: Win32 does not handle such paths, though you could break through to NTFS using the "\\\\?\\..." UNC path trick. If you happen to have such path, and it is not some mistake, probably the project is not intended to be used at Windows.

As far as understand, you have the following options:

  • ask project author to rename the file/directory in question or do it yourself
  • try using git from a cygwin/msys2 build. The msys2 wrapper handles some Windows path issues, transforming them into legal ones, though I don't know if it handles this issue.
  • fix git for windows - take into use the UNC path. The maintainer said he would consider taking such patch.
  • if you don't really need to work on the file or directory, you could exclude it from checkout using sparse checkout .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM