How to create and maintain a separate repository for the subfolder of another repository?

Asked

Viewed 43 times

1

Currently, I have a git repository with multiple folders, for example:

/pasta1
    /pasta1/subpasta1-1
    /pasta1/subpasta1-2
/pasta2
    /pasta2/subpasta2-1
    /pasta2/subpasta2-2
/pasta3
    /pasta3/subpasta3-1
    /pasta3/subpasta3-2

I want to make /pasta2/subpasta2-1 in a separate repository, because I want to push and share that code as a standalone feature. However, I want to keep this folder as part of the main repository, because its development goes hand in hand with the entire application it is part of.

How can I do it using git?

  • git branching ?

1 answer

2


You can use Git submodules, where Git manages repositories within repositories.

There is a question here in the OS you can learn more about the functionality.

  • 1

    Thanks! I followed the following steps: 1. I copied subpasta2-1 to a new directory and initialized it as an independent git repository; 2. I removed it subpasta2-1 from my original repository; 3. I ran git submodule add <novo_repositório_de_subpasta2-1> pasta2/subpasta2-1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.