Reputation: 879
I have two folders in my setup, an express backend and a react frontend which I created with npx create-react-app
. I want to push both to the same repository in the same branch but the problem is when I downloaded my react app and check my source control, it split up for some reason. I did git init
in the root directory which contained both these folders but it still split them up in the source control:
I'm not sure how to push them to the same repository, some advice or things I should do at the start would be helpful. I'm able to download my backend and create a new frontend since I haven't really done much with my frontend so if a solution which requires me to do something from the get-go of installing react arises, I can do that.
Upvotes: 3
Views: 9977
Reputation: 1
Steps to solve this problem:
Remove existing git initialization: cd frontend rm -rf .git
Then go to the backend directory and do the same:
cd ../backend rm -rf .git
Navigate to main folder:
cd ..
Initialize a New Git Repository:
git init
Add Both Folders to the Repository:
git add frontend backend
Commit the Changes:
git commit -m "Add frontend and backend folders"
Connect to GitHub Repository:
git remote add origin
Push the Changes to GitHub:
git push -u origin main
Upvotes: 0
Reputation: 328
It's likely that your frontend and backend folders each have their own .git
folders within. Which would make each of them a git repository as that's where all source control data is kept.
If you are fine with wiping out their history (not your changes/files), then delete the two .git
folders and try again from the root directory containing both folders.
Upvotes: 4