Linking Git repository to projects

Linking a Git repository to a project means connecting your local project files to a remote Git repository such as GitHub, GitLab, or Bitbucket so you can track changes, collaborate with others, and back up your code.

Before you begin

Make sure that the repository you are going to use meets the requirements, which are listed in the Configuring Git accounts section.

About this task

The Git account of the user who creates a project is used for pulling the project details from the Git repository. However, committing and pulling changes in the UI is restricted to the Git account of the logged in user. If the user did not add a Git account already, then a prompt is displayed to enter their Git username and access token. If you do not select any source control account, then the project uses the IBM hosted repository.

Procedure

  1. On the Projects page, click +.
    The New Project dialog is displayed.
  2. Enter a name for the project that you want to create in Project Name.
    The name must match the name of the Git repository you are going to use (before the Project suffix).
  3. In Source Control - Git server/account, select the source control name of the Git account that has access to the repository. The drop-down menu displays all Git accounts that you own as well as shared accounts.

    If you want to use a new Git account, click Add. For more information, see Configuring Git accounts.

    Note:
    • The Repository field lists the Git repository URL and hostname details based on your selection in the Source Control - Git server/account field. You can click Copy to copy the Git repository name. The repository name is the same as the project name suffixed by the word Project. For example, if the project name is Demo, the repository name must be DemoProject.
    • If you do not select any Git account, then the project files are stored to a Git repository, managed by IBM®.
  4. Update the repository path if needed in the Repo path field.
    For example, Git URLs for Azure repositories usually look like https://dev.azure.com/abc/MyProject/_git/MyRepo, where abc is the organization name, MyProject is the project name, and MyRepo is the repository name. When specifying the repository path, use the base path without the repo name, such as, abc/MyProject/_git.
  5. Click Open to verify the connection to the Git repository.
  6. Enter a name of the branch in the Branch field. The default branch is Main.
  7. Click Create.

Results

The project is created and linked to the specified Git repository. From now on, your project files are stored in the Git repository.

Also, an icon Project icon indicating that the project is linked to an external repository. is displayed on the project card to indicate that the project is linked to an external Git repository.

Note: Deleting a project does not remove the project assets that are stored in external Git repositories.