Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git enumerates nonexistent untracked files slowly

Tags:

I am using git for source control on a repository. Recently it has begun warning me about how long it takes to enumerate untracked files when using git status:

$ git status On branch my_branch Changes not staged for commit:   (use "git add <file>..." to update what will be committed)   (use "git checkout -- <file>..." to discard changes in working directory)      modified:   My_Project/my_source.c   It took 3.24 seconds to enumerate untracked files. 'status -uno' may speed it up, but you have to be careful not to forget to add new files yourself (see 'git help status'). no changes added to commit (use "git add" and/or "git commit -a") 

However, there are no untracked files in this repository – I checked with git status -uall. Some other possibly relevant information:

  • I've noted that this warning only appears when git status does indeed take a few seconds to run.
  • My repository is 130.6 MB at the moment.
  • My build products are all out-of-tree.

Why does git take so long to enumerate untracked files that do not exist?


Here are some relevant other questions:

  • ways to improve git status performance
  • Git Status Takes a Long Time to Complete
like image 838
ravron Avatar asked Jan 26 '15 18:01

ravron


People also ask

How do I fix nothing added to commit but untracked files?

The solution: To fix this error, you may either add the untracked files to your Git repository (as advised by the warning message) or add them to your . gitignore file. After that, either option should allow the git pull to succeed.

Why git add take so long?

Git slowness is generally from large binary files. This isn't because they're binary, just because binary files tend to be large and more complex to compress & diff. Based on your edit indicating the file sizes, I suspect this is your problem.

Do untracked files get pushed?

They won't affect pushing- only time I would see it affect pushing is if you use git add . before committing and pushing and forget about those untracked files- then they become part of your commit.


1 Answers

First, I want to acknowledge Sven Marnach's comments above that basically gave me this solution.

Problem: I had this problem too, but my HD(s) is/are fine. It takes 3-5 seconds to do a "git status" on a SSD drive and 4-8 seconds on a magnetic one. It's a lot faster after I've done it a few times. I also see this error about taking so long to enumerate untracked files but I have no changes to commit.

Quick Solution: Delete whatever files are being hidden by your .gitignore files.

Better Solution: Stop building in the same directory that is in source control.

Why: Git still has to go through all the non-tracked files, see if there any new ones and then cross-reference them against the entries in .gitignore. This error is not saying that you have files that need to be checked in, rather that it's taking a really long time these days to figure out if there's a file that needs to be checked in.

On a clean checkout where there are no files to be hidden by git ignore and an SSD drive, running "git status" takes 0.8 seconds.

One last note: This is a really old project and we have a really large .gitignore file. I suspect that reducing 100 entries down to a single directory would help too, but unfortunately we have a few files in each of these output directories that are checked in.

like image 189
Ryan Shillington Avatar answered Sep 16 '22 17:09

Ryan Shillington