Skip to content

Subtree

Eric Bouchut edited this page Apr 11, 2021 · 16 revisions

Put a folder in a Separate Branch

Assuming we have a monorepo, ie. a single git repository, containing both the back-end (server) and front-end (client) code. You want to extract the client code in another branch named for instance client.

The below command splits the client/ folder in a client branch. That is the client branch will only contain the commits related to the client/ folder.

cd monorepo

git checkout master
git subtree split --prefix=client -b client

The next will be to push this branch to another repository.

Clone this wiki locally