# Git and GitHub

You can configure and work with Git by leveraging [environment-variables](https://datalab-docs.datacamp.com/work/environment-variables "mention"). This way, you don't need to enter these details every time you want to push to or pull from a Git repository.

The following environment variables are required to connect to a Git repository. You can choose the name for this set of environment variables freely.

* `GIT_AUTHOR_EMAIL`
* `GIT_AUTHOR_NAME`
* `GIT_COMMITTER_EMAIL`
* `GIT_COMMITTER_NAME`
* `GIT_USERNAME`
* `GIT_PASSWORD`  (see below for instructions for GitHub)

![The required environment variables to connect to GitHub, the collection name can be chosen freely](https://4179539225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZqboFGZzD87nn7oPsm%2Fuploads%2FkXrhu0nJ7XmNubVjRZ2e%2FScreenshot%202022-07-12%20at%2013.48.57.png?alt=media\&token=be17256b-403c-4859-84ba-dc5e5f0cd431)

After setting up your environment variables and connecting them to your workbook, you can open a terminal by opening the **Run** menu and choosing **Open Terminal**. Run the following command:

```
$ git clone <repository_url>
```

This command will clone your git repository in a new folder using the name of the repository as the name of the folder. In order to clone into the top level directory of your workbook, the directory your terminal opens up in, you can append `.` to the command. This will only work if the current directory is empty.

```
$ git clone <repository_url> .
```

### GitHub

In order to connect to GitHub, the `GIT_PASSWORD` environment variable should be a Personal Access Token (PAT). See the [GitHub documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) to create a PAT with the right permissions.

After configuring and connecting the environment variables, you can open a terminal by opening the **Run** menu and choosing **Open Terminal**. Now you can clone a private repository for example. Make sure to use the web URL of the GitHub repository, starting with `https://`:

```
$ git clone https://github.com/<user>/<private-repo>.git
```
