Home > Back-end >  How to split a repository for front end / API / Admin access (Laravel)
How to split a repository for front end / API / Admin access (Laravel)

Time:11-05

How can you take an existing repository, with many branches, and split it so that some (new front end devs) have access to only parts of the code, but retain the history in the main/full repo?

We have a (huge) Laravel project with a few SPA parts, and 3 separate admin sections. It's all currently in one single repo. Assuming I set up an online dev server so that the API is retrieving the right data based on the branch/version they're working on, is it possible to split the repo so that I (and a few others) have access to the full codebase, while others only can clone/push/pull from a sub repo? The sub repo would exclude the admin sections and API. I assume I'll have to completely restructure the project directory, which is fine.

We all work remotely, and I'm aiming to hire a few new people but don't want to give access to the full code base right away.

CodePudding user response:

Yes, this can be done. You can use git submodules.

In this regard you can have the smaller codebase repo in a 'submodule' which lives inside your main larger repo.

Steps you'd need to take:

  • Remove the relevant code from the main repo
  • Add it to a fresh repo
  • Call the following commands from the main repo:
git submodule add [URL to smaller repo]
git submodule init

Nice article on it here

  • Related