Search code examples
gitgit-submodulesgit-subtree

How to migrate only a part (subset, folder) of one Git repository to another


I have a bitbucket repo A that I've been using for development. The production code is only a subset of the code on bitbucket repo.

I want to continue using repo A for development and migrate only the production code subset to repo B. Is this possible?

i.e.

Source repository A

(Bitbucket)

    /src
      /a.py
      /b.py

New repository B

(GitHub)

    /src
      /a.py

(repo B has no b.py).


Solution

  • This is what git-submodules are made for. If your production code can be separated to a single directory, you can use git-subtree to easily organize a submodule.

    Then you'll be able to manage production code as a separate repo and have it on GitHub without all the other code.