> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/troubleshooting-and-resources/resources/new-user/manage-cd-in-git.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# Manage Harness deployment resources in Git

Provide version control and collaboration among teams using Git.

Harness Continuous Delivery (CD) manages and automates deployments. Storing Harness CD resources in Git not only provides version control but also facilitates collaboration among teams, enabling Infrastructure as Code (IaC) practices. This guide takes you through the steps to onboard and operationalize the management of Harness CD resources in Git.

## What you will learn from this topic

* How to [onboard Harness CD resources into a Git repository](#onboarding-steps).
* How to [operationalize](#operationalization) the management of those resources with version control, continuous integration, synchronization, access control, and audit practices.

***

## Before you begin

Ensure that you have the following:

* Familiarity with Git and Git operations.
* A Harness account with relevant permissions.
* A Git account (GitHub, GitLab, Bitbucket, and so on) and repository.
* [Harness Git Experience quickstart](https://developer.harness.io/harness-platform/use-harness-platform/git-experience/configure-git-experience-for-harness-entities)
* [Import a pipeline from Git](https://developer.harness.io/harness-platform/use-harness-platform/git-experience/import-a-pipeline)

***

## Onboarding steps

Complete the following steps to move your Harness CD resources into Git.

### Step 1: Set up your Git repository

Complete the following for this step:

* If you do not already have a repository, create one.
* Clone the repository to your local machine.

### Step 2: Organize your Harness resources

Depending on your organization's needs, you can structure the Harness configurations in different directories or maintain them in a hierarchical structure.

**Example:**

```
  ├── services
  │   ├── app1
  │   └── app2
  ├── environments
  │   ├── dev
  │   └── prod
  └── pipelines
      ├── pipeline1
      └── pipeline2
```

### Step 3: Export Harness resources

Use the Harness API or the Harness UI to export your desired resources (services, pipelines, environments, and so on) into YAML or JSON formats.

### Step 4: Store resources in Git

Move the exported resources to your repository structure.

Use Git commands (`git add`, `git commit`, and so on) to track these files and push them to your remote Git repository.

***

## Operationalization

After you onboard your resources, follow these practices to manage them in Git on an ongoing basis.

### Step 1: Version control and collaboration

Complete the following for this step:

* **Branching:** Use a branching strategy to manage changes (for example, feature branching or Gitflow). This ensures that different teams or features do not interfere with each other.
* **Pull/Merge Requests:** Implement a PR/MR system. Any changes to Harness resources should be reviewed by peers before they are merged into the main branch.

### Step 2: Continuous Integration

Complete the following for this step:

* Use CI tools such as Harness CI (the free tier includes hosted builds), Jenkins, GitHub Actions, or CircleCI.
* On every commit or PR, validate the YAML/JSON configurations to ensure they are correct. This step can save significant troubleshooting time.

### Step 3: Synchronization with Harness

Regularly sync the resources stored in Git with Harness using the Harness API. This ensures that the Harness platform is always up to date with your Git repository.

### Step 4: Change notifications

Use webhooks or CI/CD pipeline notifications to alert relevant stakeholders when changes are made to Harness resources in Git.

### Step 5: Backup

While Git inherently provides version control, it remains a good practice to have backups of your Git repositories, especially for critical configurations.

### Step 6: Documentation

Inside your repository, maintain a `README.md` or equivalent documentation. Detail the purpose of different resources, the structure of the repository, and any important conventions that your team should follow.

### Step 7: Access control

Complete the following for this step:

* Ensure only authorized individuals can make changes to critical configurations.
* Use Git's access controls or integrate with identity providers.

### Step 8: Audit and compliance

Complete the following for this step:

* Periodically review the changes in your Git repository. This can be facilitated using Git's log features.
* Ensure that all changes comply with your organization's standards and best practices.

***

## Next steps

Managing Harness CD resources in Git can streamline operations, increase transparency, and bolster collaboration. By adhering to best practices in Git operations and ensuring synchronization with the Harness platform, you can efficiently manage and track changes to your deployment resources.

* [Harness Git Experience quickstart](https://developer.harness.io/harness-platform/use-harness-platform/git-experience/configure-git-experience-for-harness-entities): Configure Git Experience for Harness entities.
* [Import a pipeline from Git](https://developer.harness.io/harness-platform/use-harness-platform/git-experience/import-a-pipeline): Bring an existing pipeline definition into Harness from Git.

{% @harness-feedback/feedback %}
