Home > Enterprise >  How to create a submodule in Azure Devops?
How to create a submodule in Azure Devops?

Time:09-02

I'm trying to add a submodule to Azure Devops.

I have created two Repo's and i'd like one to be a submodule of the other. Is this the way to go? Or do you just create a folder in the main Repo which adds the submodule? Is it possible with just the azure set up wizards?

I have only found how to checkout a submodule with the main Repo and literally nothing on how to actually create the submodule.

CodePudding user response:

You need to use git command to create submodule. Here are the detailed steps:

  1. Go to the local main repository. If your repository does not exist locally, please clone it. In your repository, click "Clone" to get clone URL. Please copy it. Then, please create a new folder locally and run the following command in the directory:

    git init
    git clone {clone URL}
    
  2. Run the command:

    git submodule add {repository url}
    

    resository url: The url of your Azure DevOps repository: https://dev.azure.com/{organization}/{project}/_git/{repository}

    Then you will find a .gitmodules file automatically generated. You can open it to check the submodule name and url.

  3. Run the following command to add, commit and push the changes to Azure DevOps:

    git add .
    git commit -m "commit message"
    git push origin {branch name}
    
  • Related