> ## Documentation Index
> Fetch the complete documentation index at: https://docs.helloleo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Git Integration

> Version control and Git operations

HelloLeo integrates with Git to give you version control for your projects.

## What is Git?

Git is a version control system that tracks changes to your code. HelloLeo uses Git to:

* **Track changes** - See what Leo modified
* **Version history** - View past versions of your project
* **Collaborate** - Work with others on the same project
* **Backup** - Keep your code safe

## Prerequisites: SSH Key Setup

Before connecting a Git repository, you need to set up an SSH key. This allows HelloLeo to authenticate with your Git provider (GitHub, GitLab, etc.).

### Step 1: Generate Your SSH Key

1. Go to your [Account Settings page](/dashboard)
2. Find the "Public SSH Key" section
3. Click "Generate your Leo's SSH Key"
4. Once generated, click "Copy your Leo's Public SSH Key"

### Step 2: Add SSH Key to Your Git Provider

After copying your SSH key, add it to your Git provider:

**For GitHub:**

1. Go to [GitHub Settings > SSH and GPG keys](https://github.com/settings/keys)
2. Click "New SSH key"
3. Paste your public key
4. Click "Add SSH key"

**For GitLab:**

1. Go to [GitLab Settings > SSH Keys](https://gitlab.com/-/profile/keys)
2. Paste your public key in the "Key" field
3. Add a title (e.g., "HelloLeo")
4. Click "Add key"

**For other Git providers:**

* Check your provider's documentation for adding SSH keys
* The process is usually similar: Settings → SSH Keys → Add new key

### Step 3: Verify Setup

Once your SSH key is added to your Git provider, you're ready to connect repositories!

## Repository Connection

### Connect Existing Repository

1. Go to Project Settings
2. Enter your Git repository URL (SSH format: `git@github.com:user/repo.git`)
3. HelloLeo will clone and connect your repository

### Create New Repository

If you don't have a repository yet:

1. Create a project in HelloLeo
2. Leo will initialize Git automatically
3. Connect to GitHub/GitLab later if needed

## Git Operations

### Change Branch

Switch between different branches of your code:

* **Select branch** - Choose from existing branches
* **Create new branch** - Start a new feature branch
* **See branch status** - Know which branch you're on

### Connect Repository

Link your project to a Git repository:

* **Enter SSH URL** - Use format: `git@github.com:user/repo.git`
* **Test connection** - Verify credentials work
* **Sync automatically** - Changes sync with your repo

### Sync Status

See if your local code matches the remote:

* **Up to date** - Everything is synced
* **Ahead** - You have local changes to push
* **Behind** - Remote has changes to pull

### Version History

View recent commits:

* **See changes** - What was modified
* **View dates** - When changes were made
* **Navigate versions** - Go back to previous versions

## Understanding Git Terms

* **Branch** - A separate line of development
* **Commit** - A saved change to your code
* **Push** - Send changes to remote repository
* **Pull** - Get changes from remote repository
* **Remote** - The repository stored on GitHub/GitLab/etc.

## Best Practices

* **Regular commits** - Leo commits changes automatically
* **Use branches** - Test features in separate branches
* **Sync regularly** - Keep local and remote in sync
* **Review changes** - Check what Leo modified

## Troubleshooting

### Connection Issues

* **Check SSH URL** - Must be in SSH format (`git@github.com:user/repo.git`)
* **Verify SSH key is set up** - Make sure you've generated your SSH key on the [Account Settings page](/dashboard) and added it to your Git provider
* **Check Git provider** - Ensure the SSH key is correctly added to GitHub/GitLab
* **Test connection** - Use the test button in Project Settings

### Sync Problems

* **Pull first** - Get remote changes before pushing
* **Resolve conflicts** - Merge conflicts if they occur
* **Check branch** - Make sure you're on the right branch

<CardGroup cols={2}>
  <Card title="Project Settings" icon="settings" href="/features/project-settings">
    Configure Git repository settings
  </Card>

  <Card title="Code Editor" icon="code" href="/features/code-editor">
    Make manual edits when needed
  </Card>
</CardGroup>
