Git - Push subfolder to different repository

Viewed 6535

I have a big repository with many files and projects. One of the sub-folders in this repo has to be a new, separated repository.

I don't need to preserve history in the new one, but I have to be able, at any time, to update new repo with changes from the original repo.

The idea is that the old repo is a private, internal gitlab and the new repo is a public repo for deployed project.

How can I do this?

3 Answers

If you only ever need to update the public repository from the private repository and never in the opposite direction, you can use:

C:\privateRepo> git subtree push --prefix=public ..\publicRepo publicBranch

This will copy all commits that access the subfolder public (and the copies will only contain information about files that are in that subfolder) and push those commits into the repository in C:\publicRepo at branch publicBranch.

Related