> 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-integration/troubleshooting-and-resources/ci-articles-and-faqs/articles/use-git-credentials-from-codebase-connector-in-ci-pipelines-run-step.md).

# Use codebase connector's Git credentials in a CI Run step

Harness CI supports seamless integration with version control systems through [codebase connectors](/continuous-integration/use-harness-ci/use-harness-ci/codebase-configuration/create-and-configure-a-codebase.md). While most Git tasks are automated within the CI pipeline, there can be scenarios where you need to manually execute Git commands in a [Run step](/continuous-integration/use-harness-ci/use-harness-ci/run-step-settings.md), such as when you need to [Clone a subdirectory](/continuous-integration/use-harness-ci/use-harness-ci/codebase-configuration/clone-subdirectory.md) or run [use Git Large File Storage](/continuous-integration/use-harness-ci/use-harness-ci/codebase-configuration/static/gitlfs.md).

To facilitate this process, you can use a `.netrc` file to pull Git credentials from your pipeline's codebase connector and use those credentials in your Run step's commands.

{% hint style="info" %}
**WHAT DOES THE .NETRC FILE DO?**

Creating a `.netrc` file in a CI Run step provides a mechanism for storing Git credentials required for manual Git operations. It ensures that the necessary authentication information is readily available when executing Git commands in the Run step.

By using the `.netrc` file, you can execute Git commands within the run step without having to provide credentials each time. Git automatically references the `.netrc` file to retrieve the necessary credentials.
{% endhint %}

{% hint style="info" %}
**PRIVATE REPOS ONLY**

This article is to be used with private repos only.
{% endhint %}

1. [Configure your CI pipeline's codebase.](/continuous-integration/use-harness-ci/use-harness-ci/codebase-configuration/create-and-configure-a-codebase.md)

   Make sure to select the code repo connector with the credentials that you want to use in the Run step.
2. Add a [Run step](/continuous-integration/use-harness-ci/use-harness-ci/run-step-settings.md) that creates a `.netrc` file with the following content:

   ```
     cat <<EOF > ${HOME}/.netrc
     machine ${DRONE_NETRC_MACHINE}
     login ${DRONE_NETRC_USERNAME}
     password ${DRONE_NETRC_PASSWORD}
     EOF
   ```

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>These <code>DRONE_</code> variables are <a href="/pages/wZhd2q1uOrj1P3wmZzDq">CI environment variables</a>.</p></div>
3. In the same Run step, add your Git commands. Git automatically uses the credentials from the `.netrc` file for authentication, enabling seamless manual Git operations.

   For example:

   ```
   # Create the .netrc file
   cat <<EOF > ${HOME}/.netrc
   machine ${DRONE_NETRC_MACHINE}
   login ${DRONE_NETRC_USERNAME}
   password ${DRONE_NETRC_PASSWORD}
   EOF

   # Run Git commands
   git clone https://github.com/your/private-repo.git
   cd private-repo
   git pull origin main
   ```
