3

My git-cmd.exe window looks like this:

git add "NextFolder/*"
error: unable to create temporary file: No such file or directory
error: NextFolder/SomeFile.txt: failed to insert into database
error: unable to index file 'NextFolder/SomeFile.txt'
fatal: adding files failed

I'm adding a large number of files to a new git repo. I have over 14,000 files spread out across about 80 folders in the root level. Due to the volume I've decided to add and commit one folder at a time. Seems each folder has some number of files that cause the "git add" operation to have a fatal error (see above).

I'm using Git for Windows, portable version:

git --version
git version 2.22.0.windows.1

I believe the error is somehow related to the content of the file. I can rename the file, copy contents to a new file, rename that file, none of that will make it work. I've found that if I add a CRLF at the very bottom of the file the problem is "fixed" for that file but the git add operation just hangs up on some other file in the folder with the same condition.

I've been using Notepad++ to examine the files compared to other files that seem to get added without an issue. Line endings look the same (CRLF), encoding looks the same (ANSI), etc.

One of the comments in this thread seem to be describing my exact problem, but it's the last comment on an answer with no upvotes and the thread is 5yr old...

git - unable to create temporary file: no such file or directory - only for certain files?

I'm also fairly certain this is not a permissions issue. That's the first thing that comes up in my research but I've copied the source code, in it's entirety, to my local machine to get everything added to git. So I'm thinking it shouldn't be a permissions issue since everything is local and most of the files are getting added. Unless it's related to the volume of files or the fact I'm using Git portable.

Been banging my head against this for hours, send help!

EDIT: I should have pointed out that the git repo is seperate from the working tree. They are actually on different drives. Both are network drives, e.g. S:\path\to\tree and H:\git\test.git. This is thought to be temporary, I am attempting to characterize the frequency of changes we have on the (working tree) network location. Once I have better understanding of where we have the most churn, I'm thinking we will make smaller repos with the typical configuration, having the .git folder at the root of the working tree.

scottmwyant
  • 305
  • 1
  • 2
  • 9
  • Did you try to `cd NextFolder` then `git add .` ? – Romain Valeri Jun 19 '19 at 20:14
  • No but there have been some folders (newer folders that only have a dozen or so files) that add without a problem. I can give that a try tomorrow though. Wonder if age of the file has anything to do with it? – scottmwyant Jun 19 '19 at 20:17
  • Try taking ownership of the whole repo anyway. Copying and pasting isn't always a guarantee that you'll have permission. – evolutionxbox Jun 20 '19 at 09:32
  • "having the .git folder at the root of the working tree.": yes, as long as it is *not* on any network drive: Git is made to run locally, with as little as latency as possible. – VonC Jul 22 '19 at 13:38

4 Answers4

3

I had the same problems it seems that I had an empty directory in the project folder. I deleted this and everything was fine. Could have used an error message that told me more about the correct direction.

christiandersen
  • 193
  • 1
  • 5
1
git add "NextFolder/*"

It should be git add "NextFolder": no star/wildcard needed here, as it would be interpreted by the Git bash instead of Git itself.

First, make sure to add those files in a CMD session using a simplified PATH: that will rule out any other program influence.

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%

Second, make sure to type first:

git config core.autocrlf false

That will avoid Git trying to convert EOL on all files.

I mentioned core.fscache here, but with Git 2.22, the issue 1989 is resolved.

Do activate the core.commitGraph and add a folder (and subfolders) at a time, with a commit done after each add.

Finally, with Git 2.22, do activate trace2 for more traces.


I should point out when I had the error I had the repo separate from the worktree.
They are on different volumes.

  • The worktree is under S:\path\... and
  • the .git folder is under H:\git\test.git

Try and check if the issue persists when doing a git add in a local repository, cloned on your local disk C:\ (no network should be involved at least for the .git folder).


With Git 2.24 (Q4 2019) trace2 will be applied to commit graphs as well.

See commit 0bd7f57 (27 Aug 2019) by Garima Singh (singhgarima).
(Merged by Junio C Hamano -- gitster -- in commit ccc2899, 15 Oct 2019)

commit-graph: emit trace2 cmd_mode for each sub-command

Signed-off-by: Garima Singh
Acked-by: Jeff Hostetler

Emit trace2_cmd_mode() messages for each commit-graph sub-command.

The commit graph commands were in flux when trace2 was making it's way to Git.

Now that we have enough sub-commands in commit-graph, we can label the various modes within them.
Distinguishing between read, write and verify is a great start.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • VonC, thanks for the help, I'm just now getting back to this. I set core.autocrlf to false and GIT_TRACE2=TRUE. I'm not seeing much difference though. The trace is also showing the error text. At the end of the trace it has `code: 128`. Is this another diagnostic step? What's the next move? – scottmwyant Jul 22 '19 at 12:13
  • @scottmwyant Do you do all that in a CMD session with a simplified PATH? And can you try `git add "NextFolder"` instead of `git add "NextFolder/*"`? No star should be needed. – VonC Jul 22 '19 at 12:21
  • Yea, only thing I wasn’t sure on was changing the config for the commit graph. Just not clear on what you wanted me to do there. PATH matches exactly what you have up there. – scottmwyant Jul 22 '19 at 12:39
  • "Just not clear on what you wanted me to do there": For example, can you try adding the same file (the one which wouldrequire an additional CRLF at its end) in a separate cloned repo, to see if you ca reproduce the issue (the goal is to get the smallest possible reproducible case) – VonC Jul 22 '19 at 12:44
  • Okay, interesting. I did ‘cd NextFolder’ then ‘git init’ followed by ‘git add .’ And everything in the folder added to the index. Previously I was getting the error in this folder. So, I hope this is t a big red flag, I should point out when I had the error I had the repo separate from the worktree. They are on different volumes. The worktree is under S:\path\... and the .git folder is under H:\git\test.git – scottmwyant Jul 22 '19 at 13:00
  • "I should point out when I had the error I had the repo separate from the worktree": that... is indeed something worth pointing out (as: "pointing out in your question"). Try again in a new clone repo to add your folder, but this time, with repo and worktree in the same place (and no "git init" needed) – VonC Jul 22 '19 at 13:03
  • Error goes away when the working tree contains the .git folder. Both when it’s on the local drive and when it’s on the network drive. So I suppose I have a path forward but the error is still happening when worktree is separated from the .git folder. – scottmwyant Jul 22 '19 at 14:12
  • @scottmwyant Interesting. I know a lot of work is going on with Git 2.23 (https://stackoverflow.com/search?q=user%3A6309+%5Bgit%5D+%222.23%22), so it will be worthwhile to check if the issue would persist when that new Git release will be available. – VonC Jul 22 '19 at 14:18
1

The folder which is giving you fatal: adding files failed message on git add command is actually implying that there is another .git folder inside the folder. If you navigate to the particular folder address, you can remove the file and put git add. It should work.

Elixo
  • 11
  • 1
0

I had two repos in sub folders. Once I deleted these it worked.