# Source Control

Source control is a critical component of software development, enabling teams to track and manage updates to their codebase.

**Key Features:**

* Track and manage updates to your codebase
* Maintain control over the right version of your code
* Collaborate with team members and stakeholders efficiently

#### **Compliance Requirements:**

* The Linux Foundation platform requires access to each GitHub organization hosting your code

#### Responsibilities

The governance body and authorized community members are responsible for day-to-day administration of repositories, teams, and users, unless covered by a specific managed-services agreement with the Linux Foundation.

You can add the following Source Controls tools to your projects:

* [GitHub](#setting-up-github)
* [GitLab](#setting-up-gitlab)
* [Gerrit](#setting-up-gerrit)

## Setting up GitHub <a href="#setting-up-github" id="setting-up-github"></a>

GitHub is a web and cloud-based service that helps developers to store and manage their code, as well as to track and control changes to their code base.

You can use GitHub as a source control tool to manage your project.

To connect the GitHub account to the PCC, perform the follow steps:

1. Log in to PCC.

2\. Search for the required project. The Project dashboard appears. Click **Source Control** from the **Development** tab.

{% hint style="info" %}
You can also navigate to Source Control from the Vertical Sidebar navigation menu. Click **IT Services** and then select **Development**.
{% endhint %}

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-660d2b12d81f6e995797969f2b88c689e85ee6cf%2FSC1%20(1).png?alt=media" alt=""><figcaption><p>Source Control</p></figcaption></figure>

3. The Source Control page appears. Click **GitHub** and click the <img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-96ac0edb799db9012c283321ad1d61be09ac344c%2FPL%20Ico%20(1).png?alt=media" alt="" data-size="line"> icon available in front of **Connect**.

![GitHub](https://gblobscdn.gitbook.com/assets%2F-MEMVgDuxi7j4ZpeENUY%2F-MMBvrEsjsliBZECYf7t%2F-MMByCcDTjZ9B5Zxy5DQ%2FConnect.png?alt=media\&token=0891165d-b8cb-48a3-9253-6880ae5511dd)

4. The Connect GitHub Organization dialog box appears. Enter the **Organization Name** and click **Connect**.

{% hint style="info" %}
Make sure to enter a valid GitHub organization name.
{% endhint %}

![GitHub Organization Name](https://files.gitbook.com/v0/b/gitbook-legacy-files/o/assets%2F-MT_pAMg4FUQlUpKbPvg%2F-MTj0TQnzz-FlSQFT1oZ%2F-MTjDq0dhMrtHe11_Bun%2FConnect.png?alt=media\&token=999ec864-7477-4679-acd3-f06059c897ff)

{% hint style="info" %}

* For more information on how to create an organization, refer to [Create an Organization](https://docs.github.com/en/github/setting-up-and-managing-organizations-and-teams/creating-a-new-organization-from-scratch).
* For more information on how to transfer a repository, refer to [Transfer a Repository](https://docs.github.com/en/github/administering-a-repository/transferring-a-repository).
  {% endhint %}

5. Once the connection is set, you can see the status of GitHub project and its repositories.

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-3bca0525fb7d56da6ccedc61c2dcfa9b1a4a5f87%2FStatus.png?alt=media" alt=""><figcaption><p>GitHub Status</p></figcaption></figure>

{% hint style="danger" %}
If you change the name of your GitHub organization, you'll need to reconnect it to the PCC. The renamed organization won't be automatically connected, even if the original organization was previously connected.
{% endhint %}

### Setup GitHub Repositories <a href="#invite-users-to-organization" id="invite-users-to-organization"></a>

You can manually add the repositories to the configured GitHub server.

To add repositories to the GitHub server, perform the following steps:

1. Go to the GitHub server in the Source Control and click **+ Add Repository**.

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-b6b729c3b9307081a498197f87116accd1a3d120%2FDCO1.png?alt=media" alt=""><figcaption><p>Add Repository</p></figcaption></figure>

2. The Add Repository dialog box appears. Enter the **Repository Name, Website, and Description**. Click **Add** to add the repository.

{% hint style="info" %}
You can also enable the DCO, Issues and Wiki by using the **Enable DCO**, **Enable Issues** and **Enable Wiki** toggle button respectively.
{% endhint %}

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-4c268993bd9662d3b6f396321902ca6926a58af9%2FDCO%20-%20Copy.png?alt=media" alt=""><figcaption><p>Repository Details</p></figcaption></figure>

{% hint style="warning" %}
Install the DCO app before enabling the DCO on the repository. Refer to [GitHub DCO ](https://github.com/apps/dco)for configuration. After configuring the DCO in GitHub, you can enable the DCO in the PCC.
{% endhint %}

{% hint style="info" %}
Enabling DCO in the PCC:

* Adds branch protection rules for the default branch, so that PRs must be made before changes can be merged.
* It adds a required DCO status check for PRs
* Private repositories will show as DCO not enabled unless the Github Organization is on a Pro plan or above.
  {% endhint %}

{% hint style="warning" %}
If the DCO app is not installed and configured for the organization before DCO is enabled on a repository, all changes to the default branch will be blocked until the app is added.
{% endhint %}

**Further troubleshooting: Private Repositories cannot have DCO unless the organization is on a Github Pro plan.**

### Invite The Linux Foundation user to your Organization <a href="#invite-users-to-organization" id="invite-users-to-organization"></a>

Your project should have its own GitHub organization, separate from your company's GitHub organization, and which is not shared with other, non-Linux-Foundation projects.

If you need to, create a new GitHub organization for this project, and have a user who is an owner in both organizations transfer each project repository to this organization.

Then, invite the user “thelinuxfoundation” as an owner at the organization level (not per repository) to the GitHub organization, and connect them in Project Control Center.

{% hint style="info" %}

* We cannot accept invites unless the organization is associated with a project. Please make sure to add the project to the PCC before sending an invite to 'thelinuxfoundation" user, or the invite will not be accepted and will expire after 7 days.
* For more information on how to invite users to join organization, refer [Invite Users to an Organization](https://docs.github.com/en/github/setting-up-and-managing-organizations-and-teams/inviting-users-to-join-your-organization).
* For more information on how to transfer a repository, refer [Transfer a Repository](https://docs.github.com/en/github/administering-a-repository/transferring-a-repository).
  {% endhint %}

{% hint style="warning" %}
If your invite has expired, you must delete it and send a new invite.
{% endhint %}

### Deleting a GitHub Organization <a href="#deleting-github-organization" id="deleting-github-organization"></a>

You can delete the added GitHub organization from the PCC.

To delete the GitHub organization that is added in the PCC, follow these steps:

1. Click the **Source Control**.
2. Under **GitHub**, click on the required GitHub organization that you want to delete.

![GitHub Organization](https://files.gitbook.com/v0/b/gitbook-legacy-files/o/assets%2F-MT_pAMg4FUQlUpKbPvg%2F-MWSsYEQB2dSZ8dYMPfb%2F-MWSwCcGG1dBv-of9Ain%2FG1.png?alt=media\&token=3650f3de-977b-4541-a4d9-5cf6b3ef5dc2)

3. Click the ![](https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-6e3f188d998aa5aaf0bdb40994e7acbd675e98ec%2FSetting%20.png?alt=media\&token=ff921494-0f33-4ab3-8a73-e7ef54e9a9e1) icon and click **Disassociate**.

![](https://files.gitbook.com/v0/b/gitbook-legacy-files/o/assets%2F-MT_pAMg4FUQlUpKbPvg%2F-MWSsYEQB2dSZ8dYMPfb%2F-MWSwaLjn4A4gyhFMSNm%2FG2.png?alt=media\&token=d324770c-e5df-4ecf-9707-809e592496af)

4. The Confirm Disassociation dialog box appears, click **Delete** to delete the GitHub Organization.

![Delete](https://files.gitbook.com/v0/b/gitbook-legacy-files/o/assets%2F-MT_pAMg4FUQlUpKbPvg%2F-MWSsYEQB2dSZ8dYMPfb%2F-MWSwtzItvRTln_kth57%2FG3.png?alt=media\&token=985b3280-d2d4-418e-8e5d-dd77638baeaa)

## Setting up GitLab

GitLab is an open source code repository and collaborative software development platform for large DevOps and DevSecOps projects. GitLab helps you to automate the builds, integration, and verification of your code.

You can use GitLab as a source control tool to manage your project.

To setup the GitLab account to your project, perform the following steps:

1.Login into PCC.

2\. Search for the required project. The Project dashboard appears. Click **Source Control** from the **Development** tab.

{% hint style="info" %}
You can also navigate to Source Control from the Vertical Sidebar navigation menu. Click **IT Services** and then select **Development**.
{% endhint %}

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-660d2b12d81f6e995797969f2b88c689e85ee6cf%2FSC1.png?alt=media" alt=""><figcaption><p>Source Control</p></figcaption></figure>

3.The Source Control page appears. Click **GitLab** and click the![](https://firebasestorage.googleapis.com/v0/b/gitbook-legacy-files/o/assets%2F-MEMVgDuxi7j4ZpeENUY%2F-MM6s2eHhjQ_tQZBLg-r%2F-MM6sWbUBHCbO-u3210L%2FIcon.png?alt=media\&token=5797d8be-df9f-4f97-bb25-6c699e9d6253) icon available in front of **Connect**.

![GitLab](https://gblobscdn.gitbook.com/assets%2F-MEMVgDuxi7j4ZpeENUY%2F-MMBzyPEWoumUhMMbi3v%2F-MMC0CxSwdrHEJorgf-y%2FGitlab.png?alt=media\&token=4cec0390-4573-4d2e-9c84-4aa8e5e4b99a)

4.The Connect GitLab Group dialog box appears. Enter the **Group Name** and click **Connect**.

{% hint style="info" %}
The name of the group should be added and not the url or the ID.
{% endhint %}

![GitLab Group Name](https://files.gitbook.com/v0/b/gitbook-legacy-files/o/assets%2F-MT_pAMg4FUQlUpKbPvg%2F-MTj0TQnzz-FlSQFT1oZ%2F-MTjEYXWtQ06emjLntt6%2FConnect_Gitlab.png?alt=media\&token=5b16d66f-392d-40c9-a158-4e8d8b361c64)

5.Once the connection is setup, you can see the status of GitLab project and its repositories.

![GitLab Status](https://gblobscdn.gitbook.com/assets%2F-MEMVgDuxi7j4ZpeENUY%2F-MMBzyPEWoumUhMMbi3v%2F-MMC1IC5alHrzKrM8PIg%2FLab_Status.png?alt=media\&token=2b0ce2d2-76bf-4cfe-a1bb-1c3f0372d003)

## Setting up Gerrit

Gerrit is a web-based code review tool, which is integrated with Git and built on top of Git version control system (helps developers to work together and maintain the history of their work). It allows merging changes to Git repository when you are done with the code reviews.

1.Login into PCC.

2\. Search for the required project. The Project dashboard appears. Click **Source Control** from the **Development** tab.

{% hint style="info" %}
You can also navigate to Source Control from the Vertical Sidebar navigation menu. Click **Development** and then select **Source Control**.
{% endhint %}

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-660d2b12d81f6e995797969f2b88c689e85ee6cf%2FSC1%20(2).png?alt=media" alt=""><figcaption><p>Source Control</p></figcaption></figure>

3.The Source Control page appears. Click **Gerrit** and then click **File Ticket** to submit a ticket to configure Gerrit server for your project.

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-6871fa17e50807acf5e64504c7223784102f8fd2%2FGerrit.png?alt=media" alt=""><figcaption><p>Gerrit</p></figcaption></figure>

4\. In the Support Form, provide details such as summary, project name, Gerrit URL and description. Click **Create** to submit the request to the support team.

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-2f4d0a2e85d0c91e553fdc8c11099363680ce5e6%2FSupp%20Tick.png?alt=media" alt=""><figcaption><p>Support Ticket</p></figcaption></figure>

5.Once the support team configures the Gerrit server, the Gerrit server is added in the source control along with the associated repositories.

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-494d91fdc1e918158ae06c5139854c17026c5348%2FGerr%20and%20Repo.png?alt=media" alt=""><figcaption><p>Gerrit</p></figcaption></figure>

### Adding Repositories

You can manually add the repositories to the configured Gerrit server.

To add repositories to the Gerrit server, perform the following steps:

1.Go to the Gerrit server in the Source Control and click **+ Add Repository**.

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-20e82351d3fb858d404d72e096b1eec5ca9092a6%2FAdd%20Repo.png?alt=media" alt=""><figcaption><p>Add Repository</p></figcaption></figure>

2.The Add Repository dialog box appears. Enter the **Repository Name** and **Description** and click **Add**.

{% hint style="info" %}
You can use the toggle button if you want to enable the repository as the parent repositories for other repositories.
{% endhint %}

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-ed75dc14401088b61df7839d629af0b6b7f7819d%2FRepo%20Dial.png?alt=media" alt=""><figcaption><p>Add Repository</p></figcaption></figure>

### Updating the Repository

You can update the repository name and other changes with respect to the listed repository.

To update the repository details, perform the following steps:

1.Go to the required repository and click the ellipsis <img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-65749e02a76d117492ccdffed1446177fb687cf0%2FIcon%20(12).png?alt=media" alt="" data-size="line">icon and select Edit Repository.

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-f5885382a50706b2a3ba64134c42c09daa64c0b1%2FEdit%20Repo.png?alt=media" alt=""><figcaption><p>Edit Repository</p></figcaption></figure>

2.The Edit Repository dialog box appears. You can update the **Repository Name**, **Enable DCO** and **Description** and click **Save** to update the changes.

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-c7484bf0eabdd82d974cc506751dfad4e84cf530%2FEd%20Re.png?alt=media" alt=""><figcaption><p>Repository Updates</p></figcaption></figure>

### Making a Repository as Writeable or Readable

You can set a repository as readable from writeable or from writeable to readable. To set the repository as readable or writeable, click the ellipsis <img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-65749e02a76d117492ccdffed1446177fb687cf0%2FIcon%20(3).png?alt=media" alt="" data-size="line"> icon and select **Set Repository as Readable** or **Set Repository as Writeable**.

{% hint style="info" %}
When the repository is set as Writeable, the Read-only column is set as **Yes** and when the repository is set as Readable, the Read-only column is set to **No**.
{% endhint %}

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-5a13dceceb058e58e221b968a2aa174dea5cd7fb%2FRead%20and%20Write.png?alt=media" alt=""><figcaption><p>Read and Write Access</p></figcaption></figure>

### Hiding a Repository and Restrict All Access

You can hide a repository and restrict all access to the repository by clicking the ellipsis <img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-65749e02a76d117492ccdffed1446177fb687cf0%2FIcon%20(2).png?alt=media" alt="" data-size="line"> icon and selecting the **Hide Repository and Restrict All Access**.

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-fe249eeba4db7535060805d072af8d4127ffb21b%2FHide%20Repo.png?alt=media" alt=""><figcaption><p>Hide Repository</p></figcaption></figure>

### Deleting a Repository

You can delete the listed repository by clicking the ellipsis <img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-65749e02a76d117492ccdffed1446177fb687cf0%2FIcon%20(2).png?alt=media" alt="" data-size="line"> icon and selecting the **Delete Repository**.

<figure><img src="https://3411187760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2DCN9UgoRgMEkgnLyP-887967055%2Fuploads%2Fgit-blob-4cc92321bcf2b5578190b23ac53b7eeded1aa34c%2FDel%20Repo.png?alt=media" alt=""><figcaption><p>Delete Repository</p></figcaption></figure>
