windows Git 拉取错误:无法创建文件(无效参数)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26097568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:44:11  来源:igfitidea点击:

Git pull error: unable to create file (Invalid argument)

windowsgitfilenamestortoisegit

提问by Amol Dadas

I am trying to sync remote repo with local repo but getting following errors. Some files (which have not extention) are not getting sync with local repo on WINDOWS machine, but I could sync successfully on MAC machine.

我正在尝试将远程仓库与本地仓库同步,​​但出现以下错误。某些文件(没有扩展)没有与 WINDOWS 机器上的本地存储库同步,但我可以在 MAC 机器上成功同步。

Is there any configuration settings in WINDOWS to handle such case?

WINDOWS 中是否有任何配置设置来处理这种情况?

  1. Using TortoiseGit
  2. Windows 7 64 bit machine
  1. 使用 TortoiseGit
  2. Windows 7 64位机器

ERROR DETAILS

错误详情

git.exe clone     --progress -v  "https://github.com/xxxx/xxxxx.git" "C:\Data\GitHub\simility\vishesh-common"

Cloning into 'C:\Data\GitHub\simility\vishesh-common'...
POST git-upload-pack (200 bytes)
remote: Counting objects: 3912, done.
remote: Compressing objects: 100% (487/487), done.
Receiving objects: 100% (3912/3912), 2.70 MiB | 567.00 KiB/s, done.
Resolving deltas: 100% (1578/1578), done.
remote: Total 3912 (delta 409), reused 0 (delta 0)
Checking connectivity... error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1030050305_fantasy-trilogy-spin?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1030295038_laser-dogs?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1030315317_arizona-native-bird-painting-series?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1030315317_native-birds-ii?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1030552097_ikeyboard-0?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1030552097_ikeyboard?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1030552097_only-you-can-prevent-computercide?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1030552097_vector-cupholder-protect-your-laptop-and-your-lap?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_103055429_death-of-an-angel?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1030650665_rachel-vanslyke-making-a-new-record-together-we-ca?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1030835091_russian-trucks-of-world-war-two?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1031873800_prop-expansion-next-level?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1031873800_prop-project-expansion?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1099860912_yaw-clock?ref=users (Invalid argument)
error: unable to create file kickstarter/parsers/data/kickstarter/campaigndetails/_projects_1099992656_heavenly-sight-a-vision-out-of-blindness?ref=users (Invalid argument)
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status' and retry the checkout with 'git checkout -f HEAD'

git did not exit cleanly (exit code 128) (21746 ms @ 29-09-2014 13:32:13)

采纳答案by quetzalcoatl

If I read that log well, those files have names that end with "?ref=users"

如果我很好地阅读了该日志,那么这些文件的名称以“?ref=users”结尾

Windows does not allow you to have a '?' in a filename, just like it does not allow to have a "\" or "*". Under Linux it is possible, if you escape those characters. On Windows, I think it's not possible at all. See http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247

Windows 不允许你有一个 '?' 在文件名中,就像它不允许有“\”或“*”一样。在 Linux 下这是可能的,如果你转义这些字符。在 Windows 上,我认为这根本不可能。请参阅http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247

You will have a hard time with such names.. I actually can't come up with any idea that would allow you to sync that 1:1. You certainly can fetch them and save them under some safe names like _projects_1099992656_heavenly-sight-a-vision-out-of-blindness__ref=usersbut I don't know how to do that automatically, or how to later inform Git about that mapping, sorry..

你会很难有这样的名字..我实际上想不出任何可以让你同步1:1的想法。您当然可以获取它们并将它们保存在一些安全名称下,例如,_projects_1099992656_heavenly-sight-a-vision-out-of-blindness__ref=users但我不知道如何自动执行此操作,或者稍后如何通知 Git 有关该映射的信息,抱歉..

These filenames look like they have a HTML-query-parameters suffixed to them. Is it really required? maybe that's just some artifact that could be removed? try talking to the mantainers of the project, maybe they will be able to simply remove that odd suffix?

这些文件名看起来像是带有 HTML-query-parameters 后缀。真的需要吗?也许那只是一些可以被移除的神器?尝试与项目的维护人员交谈,也许他们能够简单地删除那个奇怪的后缀?

回答by morty

I ran into the same problem, but wasn't willing to rename or delete these files. So here's a workaround in case you can live without accessing those files using a sparse-checkout:

我遇到了同样的问题,但不愿意重命名或删除这些文件。所以这里有一个解决方法,以防您可以使用稀疏结帐访问这些文件:

Go to the .gitfolder in your repo and open the file config. (You can also edit your configuration using tortoise-git, but I havn't got it installed here.) In the [core]section add the line

转到存储库中的.git文件夹并打开文件config。(您也可以使用 tortoise-git 编辑您的配置,但我还没有在此处安装它。)在该[core]部分中添加该行

sparsecheckout = true

then go to the folder .git/infoand create the file sparse-checkout. Add something like

然后转到文件夹.git/info并创建文件sparse-checkout。添加类似的东西

*
!kickstarter/parsers/data/kickstarter/campaigndetails/*

The first line includes everything, while the second excludes all files in kickstarter/parsers/data/kickstarter/campaigndetails/. You should now be able to checkout the repo. Using wild-cards you can probably do more sophisticated excludes.

第一行包括所有内容,而第二行排除kickstarter/parsers/data/kickstarter/campaigndetails/. 您现在应该可以查看 repo。使用通配符,您可能可以进行更复杂的排除。

回答by Anukul Limpanasil

I'm using bitbucket and it has function that you can delete a problem file.

我正在使用 bitbucket,它具有可以删除问题文件的功能。

This is what I do.

这就是我所做的。

  1. Go to your repository.
  2. Choose menu "commit".
  3. Select your branch that you want to remove problem file.
  4. Go to your file and click it. You will reach the file overview that show the detail of the file e.g. your code, date time of this file committed, etc.
  5. Look at upper right corner, you will see the button with arrow down image (similar to alphabet v) click it.
  6. It will dropdown and show you rename button and delete button inside it.
  7. Then it's your choice, will rename it or delete it. Choose wisely.
  8. After you click a button. Bitbucket will show you a dialog box do as it said and commit your file with commit button.
  9. After commit you can return to sourcetree and pull your code with no problem.
  10. Enjoy!
  1. 转到您的存储库。
  2. 选择菜单“提交”。
  3. 选择要删除问题文件的分支。
  4. 转到您的文件并单击它。您将到达显示文件详细信息的文件概览,例如您的代码、提交此文件的日期时间等。
  5. 查看右上角,您将看到带有向下箭头图像的按钮(类似于字母 v)单击它。
  6. 它将下拉并显示其中的重命名按钮和删除按钮。
  7. 然后由您选择,将其重命名或删除。做出明智的选择。
  8. 单击按钮后。Bitbucket 将向您显示一个对话框,按照它的说明进行操作,并使用提交按钮提交您的文件。
  9. 提交后,您可以返回 sourcetree 并毫无问题地拉取您的代码。
  10. 享受!