7

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.

There is a similar question: 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.

The Git repo is separate 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.

4
  • Did you try to cd NextFolder then git add . ? Commented Jun 19, 2019 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? Commented Jun 19, 2019 at 20:17
  • Try taking ownership of the whole repo anyway. Copying and pasting isn't always a guarantee that you'll have permission. Commented Jun 20, 2019 at 9: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. Commented Jul 22, 2019 at 13:38

5 Answers 5

6

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

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.

8 Comments

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 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.
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.
"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)
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
|
1

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

1 Comment

The issue over here were the sub folders! Thanks
0

There are two .gitignore and .git folder in a sub folder and in the root of folder (maybe by your nodejs client and backend folder). Delete one file (especially the one whose is not in the root folder).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.