# Use Terminal for Git integration

Use Terminal to clone Git repositories and edit their contents.

Procedure: Clone a Git repository using Terminal

You can use the [Terminal](terminal.html) tool.

1. In the editor, go to `Main menu | Tools | Terminal`. This opens a terminal session.

2. Use Git CLI commands to clone a repository or get a fresh version of it in your notebook or workspace files.

3. (Optional) To use the repository in all the notebooks of the workspace, clone it to Workspace files.

4. (Optional) To access the repository contents from the notebook, import the necessary functions. Datalore provides you with code completions and documentation popups for imported Python modules.

> **Tip: Automate Terminal commands using init.sh**
> To automate running a set of Terminal commands on each notebook start,  edit the `init.sh` shell script. This allows you to do the following:
>
>
>
> * configure access to your privately owned repositories
>
> * configure the usage of your personal tokens
>
> * install non-Python dependencies
>
> * mount file directories
>
>
>
> The changes you make by editing the `init.sh` script are applied before the pip or conda package manage executes the base environment setup.
>
>
>
> To specify a username or email to access/push files to a repository, add the following configurations to your `init.sh` script:
>
>
>
>
> ```
> git config --global user.email "email@example.com"
> git config --global user.name "your_name"
> ```

To make an edited `init.sh` script available across the whole workspace, do the following using the Attached data tool:

* Make sure your Workspace files are attached to the notebook.

* Move the `init.sh` file from Notebook files to Workspace files.

Find more details about this in [Add files](add-files.html).

## Edit Git repository contents in Datalore

If you want to edit Python scripts or files available in your Git repository, you can clone the repository to your Attached data in one of the following ways:

* Select `Main menu | Tools | Terminal`. This will open a terminal session for you to execute the required Git CLI commands.

* Use Python magic commands directly inside notebook’s code cells.

> **Note:**
> Where you clone the repository depends on your goal:
>
>
>
> * To edit the repository from this particular notebook, clone it to Notebook files.
>
> * To edit the repository from any notebook of the workspace, clone it to Workspace files. For the Home workspace, attach the workspace files to the notebook explicitly if you have not done so already.

After you’ve cloned the repository to your Attached data, you will be able to edit file contents collaboratively. For Python files, you will be provided with the code completion and syntax highlighting assistance. To use the updated functions in your notebook, make sure to restart the kernel or use an autoreload extension:

```
...
%load_ext autoreload
%autoreload 2
...
```

> **Note:**
> Currently, it is not possible to edit Jupyter notebooks that are part of your cloned Git repository. To view Jupyter notebooks from the repository, you can double-click on them, and Datalore will open the notebook in a new tab.

