C
C#3mo ago
Cydo

✅ How can I take 2 existing repos (client and backend) and combine them?

I've always made my frontend and backends separate repos, and would like to instead make set it up where the frontend and client are both in the same repo. But it doesnt seem as simple as just creating a parent folder with 2 subfolders one for frontend and one for backend and then or am I wrong? I assumed you'd have one .gitignore in the root instead of a .gitignore in each subfolder? Or because how .net has solutions is it more complex?
20 Replies
ero
ero3mo ago
I would personally keep them separate, but if you want to merge them, just copy the project folders and add the projects to the combined solution (and merge any props files, configs, etc)
Pobiega
Pobiega3mo ago
Is this an ASP.NET backend with a JS-based frontend?
Cydo
CydoOP3mo ago
yes Specifically React frontend, and a .net web api backend
ero
ero3mo ago
Oh what then absolutely keep them separate
Pobiega
Pobiega3mo ago
You can certainly keep them in the same repo, but keep them separate from that point on
Cydo
CydoOP3mo ago
Is that common practice? I have them separate as of now, every repo ive ever made is separate Just thought one repo is easier to share then 2 separate ones
Pobiega
Pobiega3mo ago
.
├── src/
│ ├── Client/
│ │ ├── src/
│ │ │ └── ...
│ │ ├── package.json
│ │ └── README.md
│ └── Server/
│ ├── Blarg.Api/
│ │ └── ...
│ ├── Blarg.Data/
│ │ └── ...
│ ├── Blarg.slnx
│ └── README.md
├── .gitignore
├── .gitattributes
└── README.md
.
├── src/
│ ├── Client/
│ │ ├── src/
│ │ │ └── ...
│ │ ├── package.json
│ │ └── README.md
│ └── Server/
│ ├── Blarg.Api/
│ │ └── ...
│ ├── Blarg.Data/
│ │ └── ...
│ ├── Blarg.slnx
│ └── README.md
├── .gitignore
├── .gitattributes
└── README.md
something like this would be easy to use and pretty standard its literally just sharing a repo, but two otherwise self-contained programs
Cydo
CydoOP3mo ago
thats what i was trying to do but having the .gitignore at the root confused me
Pobiega
Pobiega3mo ago
we use this structure for our projects at work, and "combine" them in the build process (our FE is served by the backend as static files)
Cydo
CydoOP3mo ago
So, thats still one repo, and theres only .gitignore that handles "projects"
Pobiega
Pobiega3mo ago
you could have multiple gitignores, if you want you wouldnt ever really open the root folder in VS/VSCode I use rider for the dotnet project, and vscode for the client gotta go 🙂
Cydo
CydoOP3mo ago
yeah this is what i do, i just wanted to better organize my projects/git repos Alright ill look into this more, i wanna take my 2 separate repos and make them one repo, so its easier to manage, but i dont wanna fuck anything up lol
kurumi
kurumi3mo ago
Why don't you use git submodules ? You can have multiple separate repositories and one parent which combines all of your projects together
Cydo
CydoOP3mo ago
my git knowledge extends to, i can push and pull and make repos if something goes wrong , go into panic mode, i can resolve merge conflicts when they happen tho I plan to fully learn git one of the days, or at least enough to be a semi-wizard lol Alright ill look up git subtrees, I just made a new git repo and cloned both existing repos into it, but idk if thats gonna work is this a viable way to do things without subtrees? https://github.com/CydoEntis/collabparty yeah i dont wanna merge the repos together, i just want one repo where the separate frontend and backend exist. HOpefully that makes sense
mg
mg3mo ago
that's what i do currently
- root
|-api
||-.gitignore
|-client
||-.gitignore
|-.git
- root
|-api
||-.gitignore
|-client
||-.gitignore
|-.git
i might end up splitting it into separate repositories when i do automated deployments though in fact i definitely will
Cydo
CydoOP3mo ago
Wait, should I maybe keep them a seperate repos then? I've never done docker before, but I got a raspberry pi, setup a linux server and i wanna dockerize my react frontend, .net backend and mssql db and put it all on my pi, and then setup automated deployments like when i update my git repo is automatically deploys the update, is that gonna be easier as separate repos?
kurumi
kurumi3mo ago
It doesn't matter separate or not for deployment. If you wanna auto-deploy separately, then do multi-repos with multiple pipelines. Otherwise combine them into one If you do one repo then there will be situations when you only commit to backend side, but since it is multi-project repo, you will re-deploy both: backend and frontend So, if I were you, I will separate so you can deploy a small part of your project, instead of everything
Cydo
CydoOP3mo ago
Ok then ill do that, thanks When you have time can you tell me how you made this fancy explanation lol
Cydo
CydoOP3mo ago
you're the goat, thanks

Did you find this page helpful?