0

I have a private git repo for a project.

In there, a few file exist which I'd like to make available as a separate library, as they're not application specific and can be reused.

Is there a way to fork a git repo so that it contains just these few files, retaining the version history but ignoring all other files?

The other files need to be kept private, so I can't simply fork the whole repo and remove them for future commits.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
Vasu
  • 1,090
  • 3
  • 18
  • 35

1 Answers1

0

In there, a few file exist which I'd like to make available as a separate library

You should submodules.

enter image description here

Submodules is a independent project inside another project, which is self managed in its own folder.

In your case since you already have the code inside a big one repository so you will have to break it down to small pieces.


so I can't simply fork the whole repo and remove them for future commits.

To do it use this tool bfc.
In your case simply clean out the subfolders which you are changing to be submodules, and you remove them completely from your history.

enter image description here


Important note:

Following the above steps will perform a rebase on your branch, so you will have to know the consequences of a rebase which will force everyone with this branch to drop it and clone it again after your changes.

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167