19

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

ti7
  • 12,648
  • 6
  • 30
  • 60
rbeachHYP
  • 311
  • 1
  • 2
  • 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
  • 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

20 Answers20

16

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
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
  • 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
8

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
  • 400
  • 5
  • 11
  • 2
    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
6

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
  • 330
  • 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
3

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
  • 3,729
  • 2
  • 24
  • 42
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
  • 151
  • 1
  • 2
  • 11
2

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
  • 21
  • 2
2

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
  • 31
  • 3
1

OK it looks like it was something to do with the line breaks! Thank you for your guidance!

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!

I'm curious to understand the mechanics here---I'm assuming 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 had been thinking I deleted all my files (and ls-files returned nothing), does that mean that there was some file that was altered in this way during the clone so git didn't know where my files were? If so, which file would this have been?

rbeachHYP
  • 311
  • 1
  • 2
  • 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,274
  • 11
  • 14
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.

Please try it out and mark this as the correct solution, since other "workarounds" might not solve the issue of a lacking .gitignore file with node_modules in it.

MikhailRatner
  • 115
  • 3
  • 9
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
  • 65
  • 3
  • 10
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
  • 1
  • 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
  • 733
  • 7
  • 12
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
  • 1,574
  • 2
  • 21
  • 38
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
  • 31
  • 3
0
  1. Create a .gitignore file in vs code
  2. Write node_modules in that file
Sum
  • 51
  • 4
-1

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

Osama
  • 119
  • 1
  • 1
  • 11
-2

enter image description here

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

appdesigns
  • 98
  • 1
  • 10