> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/go-gitea/gitea/llms.txt
> Use this file to discover all available pages before exploring further.

# Pull Requests

> Comprehensive code review and collaboration workflow with advanced merge strategies

## Overview

Pull requests (PRs) are the primary mechanism for proposing, reviewing, and merging code changes in Gitea. They enable team collaboration through code review, automated testing, and controlled merging strategies.

## Creating Pull Requests

<Steps>
  <Step title="Create Feature Branch">
    Start by creating a branch for your changes:

    ```bash theme={null}
    git checkout -b feature/new-feature
    git add .
    git commit -m "Implement new feature"
    git push -u origin feature/new-feature
    ```
  </Step>

  <Step title="Open Pull Request">
    Navigate to the repository in Gitea and click **New Pull Request**
  </Step>

  <Step title="Configure PR Details">
    * Base Branch: Target branch for merge (usually main)
    * Compare Branch: Your feature branch
    * Title: Descriptive PR title
    * Description: Detailed explanation of changes
    * Reviewers: Request reviews from team members
  </Step>
</Steps>

## Code Review

### Review Process

Gitea provides a comprehensive code review workflow:

* **Inline Comments**: Comment on specific lines of code
* **Suggested Changes**: Propose code modifications that can be applied directly
* **Review Status**: Approve, request changes, or comment
* **Conversation Resolution**: Mark comment threads as resolved

### Review Requirements

Configure branch protection to enforce review requirements:

* Minimum number of approvals
* Required review from code owners
* Dismiss stale approvals on new commits
* Block merge until all reviews are approved

## Merge Strategies

Gitea supports multiple merge strategies:

<CardGroup cols={2}>
  <Card title="Merge Commit" icon="code-merge">
    Creates a merge commit preserving full history
  </Card>

  <Card title="Rebase" icon="timeline">
    Rebases commits onto base branch for linear history
  </Card>

  <Card title="Squash" icon="compress">
    Combines all commits into a single commit
  </Card>

  <Card title="Fast-Forward" icon="forward">
    Only if fast-forward is possible (no divergence)
  </Card>
</CardGroup>

### Merge Commit

Preserves complete commit history:

```bash theme={null}
git checkout main
git merge --no-ff feature/new-feature
```

### Rebase and Merge

Rebases feature branch commits onto base branch:

```bash theme={null}
git checkout feature/new-feature
git rebase main
git checkout main
git merge feature/new-feature
```

### Squash and Merge

Combines all commits into one:

```bash theme={null}
git merge --squash feature/new-feature
git commit -m "Add new feature (#123)"
```

## Automated Checks

### Status Checks

Integrate CI/CD pipelines and automated testing:

* **Gitea Actions**: Run workflows on PR events
* **External CI**: GitHub Actions, Jenkins, Travis CI
* **Status API**: Report check results via API

### Required Checks

Configure required status checks in branch protection:

```yaml theme={null}
# .gitea/workflows/pr-checks.yml
name: PR Checks
on:
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run tests
        run: make test
      - name: Lint code
        run: make lint
```

## Merge Conflict Resolution

When conflicts occur:

<Steps>
  <Step title="Update Your Branch">
    ```bash theme={null}
    git fetch origin
    git checkout feature/new-feature
    git merge origin/main
    ```
  </Step>

  <Step title="Resolve Conflicts">
    Edit conflicting files and resolve markers:

    ```
    <<<<<<< HEAD
    your changes
    =======
    incoming changes
    >>>>>>> origin/main
    ```
  </Step>

  <Step title="Complete Merge">
    ```bash theme={null}
    git add .
    git commit -m "Resolve merge conflicts"
    git push
    ```
  </Step>
</Steps>

## Advanced Features

### Draft Pull Requests

Create work-in-progress PRs:

* Mark PR as draft to indicate it's not ready for review
* Prevents accidental merging
* Convert to ready when complete

### Auto-Merge

Schedule automatic merging when conditions are met:

* All required checks pass
* Required approvals obtained
* No blocking reviews

### Pull Request Templates

Create `.gitea/pull_request_template.md`:

```markdown theme={null}
## Description
<!-- Describe your changes -->

## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update

## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests pass
- [ ] Manual testing performed

## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No new warnings generated
```

## Best Practices

<CardGroup cols={2}>
  <Card title="Keep PRs Small" icon="minimize">
    Smaller PRs are easier to review and merge faster
  </Card>

  <Card title="Clear Descriptions" icon="file-lines">
    Explain what, why, and how of your changes
  </Card>

  <Card title="Link Issues" icon="link">
    Reference related issues (Fixes #123)
  </Card>

  <Card title="Respond Promptly" icon="comments">
    Address review feedback quickly
  </Card>
</CardGroup>

## See Also

<CardGroup cols={2}>
  <Card title="Issues" href="/features/issues">
    Issue tracking and project management
  </Card>

  <Card title="Actions" href="/features/actions">
    CI/CD with Gitea Actions
  </Card>

  <Card title="Repositories" href="/features/repositories">
    Repository management features
  </Card>

  <Card title="API Reference" href="/api/pull-requests">
    Pull Request API endpoints
  </Card>
</CardGroup>
