How to merge git files in one directory and add the files to the staging area

How to initialize a git repository on a directory that contains a subdirectory that has git already initialized?

I am working on a MERN application and I have created a root folder "chatapp".

Inside the root directory, there are two sub-directories:

  1. client

  2. server

I am using React for the frontend and react comes with git already initialized.
I want to initialize git inside my root directory which contains the client subdirectory with git already initialized.

And when I run git init, it initialized well but when I run git add to stage the files for commit, it brings an error: screenshot of my code editor

I need to add both the client and server files to my git repository.
Do I need to first initialize git in the server file separately then merge or how do I add both files to the staging area?

How can I add do this without seeing the error to avoid conflicts in the repository?
Thank you,

16 thoughts on “How to merge git files in one directory and add the files to the staging area”