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

8

63

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.

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

  1. Using TortoiseGit
  2. Windows 7 64 bit machine

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)
Crispas answered 29/9, 2014 at 10:19 Comment(0)
C
31

If I read that log well, those files have names that end with "?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

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=users but I don't know how to do that automatically, or how to later inform Git about that mapping, sorry..

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?

Canoness answered 29/9, 2014 at 10:37 Comment(0)
H
61

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 .git folder 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

sparsecheckout = true

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

*
!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.

Hidie answered 29/12, 2015 at 17:26 Comment(3)
This worked, although I discovered later that it was a permissions problem. On my Windows machine, I had to uncheck some "read-only" boxes and everything worked again.Tuckie
@Tuckie Please explain what you mean by uncheck some "read-only" boxes?Outbuilding
I can't remember because it's a while ago, but probably I meant that you need to select some files, right click, go to "properties" and untick the "read-only" boxes.Tuckie
C
31

If I read that log well, those files have names that end with "?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

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=users but I don't know how to do that automatically, or how to later inform Git about that mapping, sorry..

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?

Canoness answered 29/9, 2014 at 10:37 Comment(0)
C
4

For me, this error occured when I was working on Windows machine. And git repo was cloned inside One-Drive. Altimately, after changing git location to outside One-Drive worked for me. Somehow, One-Drive couldn't update the file index I was trying to commit. Either you can try outside of One-Drive location or try resetting to previous commit and then update.

Cervelat answered 24/8, 2022 at 6:25 Comment(3)
This is correct. OneDrive sync was creating issue.Transcontinental
Are there any steps to resolve this issue without moving outside onedrive? git reset --soft HEAD~1 doesn't work for me.Sebastien
@Sebastien I think reset --hard should work.Cervelat
L
3

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

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!
Ledger answered 16/9, 2017 at 19:38 Comment(0)
R
2

In general if you get this git "invalid argument" error on Windows, try making sure your /.git/ folder is not set to "read only". This fixed it for me.

Recitative answered 26/11, 2022 at 7:16 Comment(0)
M
0

I ran into this and tried a few of the solutions above with no success.

What I did is weird but worked for me, I:

  1. Copied all my changes for the 1 file I had issues to notepad
  2. Reverted changes in GIT
  3. Copied the text from notepad with my updated code
  4. Saved the file with the changes again
  5. Used Git Desktop to push the changes
  6. This time it worked.

I did this for 2 different files and it worked for me at least. Easy/quick thing to try before you try the others if you only have a file or 2 causing the issues.

Most answered 29/6, 2022 at 14:27 Comment(0)
O
0

I was also facing "Git: unable to write file, invalid object" and try many ways but nothing has been worked. Alterably I tried simple way i have created new repo folder at my local and take checkout again of the branch and implement changes. then commit and it works.

Please note before doing just take back of the changes or if you are creating new folder for repo then dont delete till your changes committed into folder.

Ockeghem answered 12/9, 2022 at 10:35 Comment(0)
C
0

Something similar happened to me locally: I was suddenly unable to do git add -A and got this message:

error: unable to write file .git/objects/99/8fe363fa337daab318f7fc378727d9dcce28d5: Invalid argument error: [some file].js: failed to insert into database error: unable to index file '[some file].js' fatal: adding files failed

I removed the file from the repo (temporarily copied it elsewhere), commited and pushed the repo (without the problematic file) to GitHub. Then, in GitHub, I manually added the file and commited.

At this point, pulling to my local machine failed. I deleted the directory/repo and got a fresh clone from GitHub. It's a weird solution but it seems to work.

Corrugate answered 18/11, 2022 at 10:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.