BitBucket – Create repository and sub modules

I am using bitbucket web interface and have created a new project “Test_Project”.
In this project, I am able to create a new repository – ‘Module1’ using Create repository option.

Now I want to create repository hierarchy in bitbucket project – Test_Project as following :-

Test_Project (Bitbucket project)

  • Web (Repository 1)

     Module1 (Sub-Repository/Sub-module 1)
     Module2 (Sub-Repository/Sub-module 2)
     Module3 (Sub-Repository/Sub-module 3)
  • Mobile (Repository 2)

     Module1 (Sub-Repository/Sub-module 1)
     Module2 (Sub-Repository/Sub-module 2)
     Module3 (Sub-Repository/Sub-module 3)
  • Archive (Repository 3)

     Module1 (Sub-Repository/Sub-module 1)
     Module2 (Sub-Repository/Sub-module 2)
     Module3 (Sub-Repository/Sub-module 3)
  • Project Documents (Repository 4)

    And so on..

So that I will add the local projects in respective bitbucket sub repositories

Can anyone please guide how to create the sub-repositories/sub-modules in new repository in bitbucket.

  • Git one-liner to add everything (including untracked files) and commit
  • Untangle two lines with `git add -p`
  • Broke my local git repo
  • Manually editing using git add --patch <filename>
  • Git add Folder with Existing Git Repository
  • What's the difference between “git add -u” and “git add -A”?
  • Adding Only Untracked Files
  • Git: Creating alias for “add --update TOPLEVEL_DIR”?
  • 2 Solutions collect form web for “BitBucket – Create repository and sub modules”

    You simply need to be in your root folder and then add the submodule folder.

    git submodule add <url>

    Now when you clone the project you simply need to init and update the submodule

    git submodule init
    git submodule update

    Git 1.8.2 features a new option –remote

    git submodule update --remote --merge

    will fetch the latest changes from upstream in each submodule, merge them in, and check out the latest revision of the submodule. As the docs put it:


    This option is only valid for the update command. Instead of using the superproject’s recorded SHA-1 to update the submodule, use the status of the submodule’s remote-tracking branch.

    This is equivalent to running git pull in each submodule.

    Git 2.8 update

    Parallel fetches of submodules

    Using git submodules, one Git repository can include other Git repositories as subdirectories1. This can be a useful way to include libraries or other external dependencies into your main project. The top-level repository specifies which submodules it wants to include, and which version of each submodule.

    When you fetch into the top-level repository, you typically want to fetch into the submodule repositories as well:

    git fetch --recurse-submodules

    If you have a lot of submodules, all of these fetches can be time-consuming; git fetch is essentially run in each submodule in turn.

    But now you can speed things up by fetching from multiple submodules in parallel. For example,

    git fetch --recurse-submodules --jobs=4

    Now, I am able to create Bitbucket Repository Structure with sub-repository/sub-folders.

    Please follow these steps:-

    1. Create a new Repository in Bitbucket project.
    2. To interact with your new repository, you’ll need to clone this repository to your local machine using a git client.
      I am using ‘SourceTree’ as a GIT client (another Atlassian product, integrates well with Bitbucket, you can use a “Clone To SourceTree” button in Bitbucket to make things easier).
    3. Once you have a local repository, copy/move your project into it , and use your chosen tool to add/commit the files and push them to bitbucket.



    Git Baby is a git and github fan, let's start git clone.