28

I am setting up VS Code to work on an existing Salesforce project saved in BitBucket.

I cloned the repository down to my device and now when I open VS Code I get the message

The git repository at 'C:\Users[my repository directory]' has too many active changes, only a subset of Git features will be enabled.

When I go to Git in the left hand menu, it says I have 5000 staged changes and it appears to think those changes are that I deleted the files even though I can see them when I go to the file path myself.

Suggestions?

Visual Studio Code details:

  • Version: 1.42.0 (user setup)
  • Commit: ae08d5460b5a45169385ff3fd44208f431992451
  • Date: 2020-02-06T10:51:34.058Z
  • Electron: 6.1.6
  • Chrome: 76.0.3809.146
  • Node.js: 12.4.0
  • V8: 7.6.303.31-electron.0
  • OS: Windows_NT x64 10.0.18362

Message & Git output

Guildenstern
  • 2,179
  • 1
  • 17
  • 39
rbeachHYP
  • 409
  • 1
  • 4
  • 5
  • Can you clarify the folder where this repo is? I understand that you have removed personally identifying information with "[my repository directory]" but I think more details will help us help you. Like for example, you left out the \ after `Users`. Is your repository in `C:\Users\myrepo`? Or is it in `C:\Users\MyUserName\myrepo` or is it in `C:\Users\MyUserName\Documents\myrepo`? – Code-Apprentice Feb 11 '20 at 00:48
  • this could be an EOF issue. what OS are you using? – AliReza Sabouri Feb 11 '20 at 00:52
  • 1
    try this command `git config core.autocrlf true` – AliReza Sabouri Feb 11 '20 at 00:53
  • Sorry for the missing backslash----the full path it references is C:\Users\RachelBeach\Documents\Salesforce\VS Code\hyp_re-vs-code-backup – rbeachHYP Feb 11 '20 at 01:57
  • AliReza, interesting idea...I'm using Windows 10 and it is highly likely that the person who created the repository was using a Mac. I tried running that commend in the terminal window in VS Code and then restarted VS Code. I got the same problem but is there more I should be doing? – rbeachHYP Feb 11 '20 at 02:02

23 Answers23

24

A different explanation, not listed yet, might help you if two things are true

  1. you have a .git folder higher up in the folder hierarchy that you are not aware of
  2. your project that you are working on in VS code does not have an own .git folder

the 2. point is easy to verify.

Regarding the 1. point, you need to write the following in your terminal while being in the directory of your affected project:

git rev-parse --show-toplevel

This command searches a .git folder that is higher up in the directory tree of your files and it will return the location of the first encountered git repository. This means you either will receive a fatal not found or a path.

Go to this directory and delete the .git folder (after checking the log to see that you won't loose information) and then create a .git folder in your project directory.

Yves Boutellier
  • 1,286
  • 9
  • 19
  • 8
    I accidentally had a .git folder in my home directory that caused this. I deleted it and now things work as normal. – saner May 22 '22 at 23:51
20

Check with git ls-files --eol (Git 2.8+) if this is an eol issue.

If yes, then:

  • type git config --global core.autocrlf false
  • re-clone your repository
  • check if the issue persists on VSCode
snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • So git ls-files and git ls-files --eol both have no output (see screenshot). You did say it was with Git 2.8+ and I have 2.25 but the website says that's the most up to date build and was updated three weeks ago https://git-scm.com/download/win. Would you recommend still re-cloning? – rbeachHYP Feb 11 '20 at 18:58
  • 2
    @rbeachHYP Regarding eol conversion, see https://stackoverflow.com/a/14039909/6309 (and the answer below that, which is mine, about the better practice of `.gitattributes` `core.eol` directives) – VonC Feb 12 '20 at 21:16
  • @rbeachHYP "If so, which file would this have been?" Potentially binary files. The drawbacks of `core.autocrlf` is that it converts *everything. – VonC Feb 12 '20 at 21:17
10

Here is a summary of possible causes, from prior answers to this post:

  • Missing .gitignore file

  • Missing entries in .gitignore for files or folders that should not be committed to git.

  • You just made a lot of manual changes or you used an external tool which did that. VsCode needs some time to process the changes.

  • Your .git folder is higher up in the folder hierarchy than it should be.

  • You need to open just the project you want to work on instead of a parent project.

  • Try the terminal or GUI to open the project instead of dragging a project folder into VsCode.

  • Check that you didn't do your "git init" in the wrong place, especially if in a parent folder of the project.

  • An eol issue. Type: "git ls-files --eol" (Git 2.8+). If yes, then:

type: git config --global core.autocrlf false
re-clone your repository
check if the issue persists on VSCode
John Pankowicz
  • 4,203
  • 2
  • 29
  • 47
9

My resolution was fortunately straightforward. I accidentally deleted .gitignore when copying a project and once I restored that file the problem was resolved.

Andy Gup
  • 360
  • 2
  • 4
  • This is somewhat similar to my case. I have four WordPress plugin files that I work with. I never had a .gitignore file at all, but when I added one to the root of the project the problem went away. – Eugene van der Merwe Feb 18 '21 at 12:43
  • 1
    Having `node_modules` with many dependency files/folders inside, vscode can't handle the changes inside the directory. Basically, adding `node_modules` to `.gitignore` resolves the issue. – Doğukan Çağatay May 09 '21 at 19:15
8

Had the exact same problem.

  1. In vscode Right click on "SOURCE CONTROL" at the top of open source control panel, then make sure "Source Control" is selected.

  2. Open the drop down "SOURCE CONTROL REPOSITORIES" next to the top of the source control panel and right click on the repo which is incorrectly set and select "Close Repository".

Here is a visual of the answer

Vegozzy
  • 91
  • 1
  • 3
4

So what happened in my case , I opened GitBash and typed git init to initialize a repo but , what actually happened was my C drive whole folder was made a repo and that is why it was showing 10000 changes detected to revert the changes or discard , Remove the directory :

  1. Open git bash
  2. Type rm -rf .git on it and press enter
  3. This command will remove that repo no files will be deleted its safe to use
  4. create a new repo to push
Akash_Sri
  • 41
  • 2
2

The problem is that vs code needs some time if you do a huge amount of change. This generally happens when you delete or add files manually to the repository. First of all,

  • Don't sync before commit.
  • If you see a clock icon on "the source control tab", just wait. Because you can not commit before that icon gone.
  • If you try to sync then it goes into a loop.

Literally, the solution is waiting until to see the number of changes on the source control tab. Then commit and sync.

blackman
  • 171
  • 1
  • 2
  • 11
1

OK it looks like it was something to do with the line breaks!

I deleted the local files, updated the global configuration settings to set autocrlf to false (and I ended up having to change another global config setting core.longpaths to true as well). Then I re-cloned and it's all working now!

My assumption is that the autocrlf setting takes the remote files and edits all the line feeds to make them match the way your OS does line feeds.

So since git thought I deleted all my files (and ls-files returned nothing), that maybe mean that there was some file that was altered in this way during the clone so git didn't know where my files were.

blackgreen
  • 34,072
  • 23
  • 111
  • 129
rbeachHYP
  • 409
  • 1
  • 4
  • 5
0

I my case, the issue was solved by changing the way I open VS Code.

When I dragged the project folder into a VS Code window just opened, then the "too many active changes" message appeared, perhaps VS Code interpreted the current project as the previous one charged.

Instead, when I go to the project folder and put "open with" and select VS Code the problem goes away.

Mario Andrés
  • 107
  • 1
  • 8
0

I was running an external tool that made a lot of changes quickly while I had the project open in CODE and this happened. The only thing that fixed it was re-cloning the entire repository to a new directory.

C.M.
  • 1,474
  • 13
  • 16
0

I had the same issue and found a thread with a very straight-forward solution.

The problem was that I cloned a repository and did not have a .gitignore file.

  • I simply added the .gitignore file to the root folder,
  • wrote node_modules into it,
  • saved, and the problem was gone.

Here is the link to the thread: https://forum.freecodecamp.org/t/vs-code-has-5000-files-that-need-to-be-commit/250686/5

Other projects I worked on also have this line in their .gitignore file, so I guess this is a standard. Also, it does make sense, since as developers we do not want to up-and download all node modules to git but use the package.json file to share the information on which modules we need to work on the particular project.

snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
MikhailRatner
  • 452
  • 6
  • 13
0

The problem has occurred many times for me. The solution is to make sure that you open your project correctly. For example i have a map called backend and into that map i have another map called project(here is my cloned project). When i open vscode i open the map "project" directly instead of "backend".

JOHn
  • 63
  • 3
  • 11
0

Honestly, by disabling github extension in VSCode will not solve your problem.

**Check the package.json file and see what "dependencies" are causing the overload **

Example Simply npm uninstall "parcel" This will allow some of those node-modules to clear up.

**If you still would like to add the node-modules && other large packages simply: **

  1. Create a .gitignore.text or use the new file button
  2. type \{enter file name} and it will automatically add all of the children files to .gitignore
  3. git commit -m "" and then you are finished
jking026
  • 11
  • 3
0

You might have DELETED many projects from your current folder, while git didn't register the deletion.

The simplest solution is to create a new folder and start running VSCode in it.

You can delete the whole old folder, or you can leave it alone. It's up to you.

William Hou
  • 1,251
  • 14
  • 17
0

I solved my similar problem by but exiting out of VS Code and using the command line / terminal to add, commit then push files.

Tristanisginger
  • 2,181
  • 4
  • 28
  • 41
0

Just adding my own silly reason for causing this issue incase it helps another...

I cloned a repository from GitHub and then created a python environment ("env") within the same folder in order to install the requirements. It was of course all the new files in my "env" folder that caused VScode to complain about too many changes. Adding "env" to the project's .gitignore resolved the issue.

aid
  • 136
  • 3
0

Had the exact same problem.

  1. In vscode Right click on "SOURCE CONTROL" at the top of open source control panel, then make sure "Source Control" is selected.

  2. Open the drop down "SOURCE CONTROL REPOSITORIES" next to the top of the source control panel and right click on the repo which is incorrectly set and select "Close Repository".

Here is a visual of the answer

Vegozzy
  • 91
  • 1
  • 3
0

The git command git add -A ./** saved my life.

Until using this command nothing was working. I also renamed my current directory, went through and removed every single already present .git directory throughout, including the project root and all sub-directories. Added a very new and thorough .gitignore to the project root, and deleted the old remote repository that was previously started but wouldn't finish properly, all of which finally allowed me to start completely over with a brand new clean slate.

As a quick side note - The only trade-off I made (which was more of a personal choice than a trade-off really, anywho...) was for each sub-directory that already contained a .git folder, I could have included those directories as git sub-modules instead of completely deleting those .git directories, which is really the more ideal or proper way of doing it. This was a personal decision, but most likely you will want to make sure to include them as sub-modules rather than deleting them, this way it will allow you to keep not only those repositories commit histories, but also continue to fetch future upstream changes and merge them back into your working directory, so just quick fyi and word of caution here. If you delete them as I did, you will lose all of that, which is probably not what most would want to do I think, so just fyi here!! - Hope that helps somebody!!

The following documentation allowed me to make all of these decisions, which you, yourself, might find useful, just as I did:

Per the git man pages for git add

-A short for --all "Updates the index not only where the working tree has a file matching <pathspec> but also where the index already has an entry. This adds, modifies, and removes index entries to match the working tree.

If no <pathspec> is given when -A option is used, all files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories)."

Furthermore if you look in their glossary under "glob" you will find usage for a double asterisks like so:

"A trailing /** matches everything inside. For example, abc/** matches all files inside directory abc, relative to the location of the .gitignore file, with infinite depth."

0

In my case another extension seems to be the problem. Check if you have any additional Git extensions installed. If so uninstall them and reload your VS Code window.

In my Case "Git Graph" seemed to interfere for some reason.

Bassrelic
  • 90
  • 11
0

For Mac users do these steps:

Actually the issue is all because you have .git folder in your main root, so to solve this issue do these steps:

1-Open your terminal and go to your main computer root.

2-Write this >> git ls -a to find all hidden files and folders, .git will be one of them.

3-Then write this rm -rf .git to remove .git folder. Dont worry it will not ruin anything.

4-Now reopen your current project you see your source control on Visual Studio is clean.

DONE

Awara Amini
  • 307
  • 1
  • 6
-1

Always keep .gitattributes and .gitignore file to avoid such issue

Osama
  • 133
  • 1
  • 2
  • 13
-1

My problem is that I accidentally typed git add . in my users/folder on Win10 lol

-4

enter image description here

The workaround for me is to Simply disable the git extension.

appdesigns
  • 114
  • 1
  • 11