0

I have created a full-stack web application using Mern stack, but when I now try to upload the file to GitHub the terminal is hanging. And in VsCode it is showing 9k+ file changes in the source control panel, below I have attached all the images

ProjBackend is here

projfront end is attached below

Projfrontend file is here

I have created a git repository in the main file, I have deleted the .git file in the front end of my application(As while using react it will be automatically created), there is only one .git in the main file.

I am not able to add anything, the command git add .

enter image description here

the terminal will hang when I use it, the terminal won't respond. Can anyone help here? How to upload these files to GitHub and clarify what is happening, why it is coming like this.

After entering git status enter image description here

Aravinda KS
  • 187
  • 1
  • 16
  • Did you skipped node_modules to be published to Github ? – Rebai Ahmed Nov 01 '21 at 09:37
  • @RebaiAhmed Noo – Aravinda KS Nov 01 '21 at 09:50
  • 1
    Just check these answers: https://stackoverflow.com/questions/29820791/git-ignore-node-modules-folder-everywhere, try to skip node-modules and try again to make git add – Rebai Ahmed Nov 01 '21 at 10:03
  • @RebaiAhmed the error remains the same – Aravinda KS Nov 01 '21 at 10:22
  • do you have a `.git` folder in a parent folder, use `git status` to see which files are (un)tracked, get a list of all the 9K files, or view the scm bar – rioV8 Nov 01 '21 at 10:32
  • Can you tried to install Gitbash ? instead of using vscode terminal – Rebai Ahmed Nov 01 '21 at 11:13
  • @rioV8 i have ```.git``` in parent folder, and i saw all 9k files, but those are all the changes made for whole project, but I was adding day by day, so it can't be 9k by now – Aravinda KS Nov 01 '21 at 11:28
  • @RebaiAhmed Yes, the problem remains same, when I use git add, it is hanging – Aravinda KS Nov 01 '21 at 11:29
  • 2
    With that many files, it's clear you need a `.gitignore` to tell Git to ignore those generated files and folders that are not part of your source code. `git status` should tell you what they are, but you'll have to be patient when you run it, since it might have to scan all 9K+ files for you and display their status. `git add .` is certainly a bad idea at this point: you don't want to commit all that stuff! – joanis Nov 01 '21 at 12:21
  • @joanis I have uploaded the image which shows the status, when I give ```git status```, please have a look into it – Aravinda KS Nov 01 '21 at 12:28
  • where are all the 9K files, they are not shown in your status image (what is wrong with copy paste text), or are these files in `projbackend` – rioV8 Nov 01 '21 at 12:37
  • 1
    It looks like your entire `projfrontend` and `projbackend` are not in Git yet. How many files are in those folders? (e.g., `find projfrontend | wc` and `find profbackend | wc` will tell you). Do you really mean to add *all* the files in those two folders to your Git repo? `git add .` will recursively scan and add everything it finds that is not excluded by your `.gitignore`. – joanis Nov 01 '21 at 12:37
  • 1
    In one of my node projects, I just did `find node_modules | wc` and it told me I have 22081 files in there. In that case, adding `node_modules` to my `.gitignore` would be essential, as you were asked in the very first comment in this thread. When you said "same error", I might guess you didn't do it correctly, or else it's up to you to find out the name of the folder with thousands of files in it in your project. – joanis Nov 01 '21 at 12:41
  • @joanis yeah correct, it has been solved now, the ```.gitignore``` was not ignoring node_modules, so I added again clearly "node_modules" to ```.gitignore``` now it is solved – Aravinda KS Nov 01 '21 at 12:48
  • 1
    Glad yo know it's solved now. This is a very common situation, for every project you have to make sure you have a suitable `.gitignore` associated with it. – joanis Nov 01 '21 at 12:50
  • Note that even a hundred thousand files should take at most a few minutes to `git add`. (At, e.g., a mere 10 files per second, 100_000 files is 10_000 seconds or under 3 hours, and at the more reasonable 1000 files per second it's 100 seconds or under 2 minutes. ) Of course you almost certainly don't want to bother with all the generated files. – torek Nov 01 '21 at 22:34

1 Answers1

1

By adding touch .gitignore && echo "node_modules/" >> .gitignore && git rm -r --cached node_modules

in all the subfolders and in the main project folder, this problem has been solved.

Aravinda KS
  • 187
  • 1
  • 16