# Pulling Variables to Local

> Export all environment variables from a GitLab repository to your local environment.

- Course: [Introduction to CI/CD Pipelines (advanced)](https://git-nrw-4c1b28.pages.git.nrw/en/courses/ci_intermediate_course/index.md)
- Section: git-vars package

### Pulling Variables to a Local File

Export all environment variables from a GitLab repository to your local environment.

#### Prerequisites

Create a private directory outside the repository. Exported variables are plaintext secrets and must never be committed.

```bash
cd /path/to/your/repository
umask 077
mkdir -p ../ci-vars
```

#### Using Command Option

```bash
git-vars pull -s project -f ../ci-vars/project.env

# -s --scope (Optional): Need to choose one from 'project', 'group' or 'instance'. Default: The one provided in the `.git-vars` configuration file.
# -f --file: Output file where the variables are going to be exported. Always use a protected path outside the repository.
```

Verify that `../ci-vars/project.env` was created with permissions that only allow your account to read it. Do not print real secrets to a shared terminal or job log. A redacted file uses the following format:

```
TEST=<REDACTED>
AWS_ACCESS_KEY_ID=<REDACTED>
AWS_DEFAULT_REGION=eu-central-1
AWS_SECRET_ACCESS_KEY=<REDACTED>
```

Variables follow the format `KEY=VALUE`. Delete the export securely when you no longer need it.

---

- Previous lesson: [`git-vars` Configuration](https://git-nrw-4c1b28.pages.git.nrw/en/courses/ci_intermediate_course/lesson_2_3/index.md)
- Next lesson: [Pushing Variables to GitLab Safely](https://git-nrw-4c1b28.pages.git.nrw/en/courses/ci_intermediate_course/lesson_2_5/index.md)
