7

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.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
Jatin
  • 197
  • 2
  • 5
  • 17

2 Answers2

15

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:

--remote

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
Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • Hi, I am able to add submodule folder in my local root folder by using **git submodule add ** Now I want to push this local root folder containing sub-modules on Bitbucket server but I am unable to do it. While pushing, it gives message as following:- $ git push -u origin --all No refs in common and none specified; doing nothing. Perhaps you should specify a branch such as 'master'. Everything up-to-date Please guide how to create and push the sub-repositories/sub-modules in new repository in bitbucket. – Jatin Mar 31 '16 at 11:25
-7

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.

Thanks,

Jatin

Jatin
  • 197
  • 2
  • 5
  • 17