Skip to main content

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

1

Create Feature Branch

Start by creating a branch for your changes:
git checkout -b feature/new-feature
git add .
git commit -m "Implement new feature"
git push -u origin feature/new-feature
2

Open Pull Request

Navigate to the repository in Gitea and click New Pull Request
3

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

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:

Merge Commit

Creates a merge commit preserving full history

Rebase

Rebases commits onto base branch for linear history

Squash

Combines all commits into a single commit

Fast-Forward

Only if fast-forward is possible (no divergence)

Merge Commit

Preserves complete commit history:
git checkout main
git merge --no-ff feature/new-feature

Rebase and Merge

Rebases feature branch commits onto base branch:
git checkout feature/new-feature
git rebase main
git checkout main
git merge feature/new-feature

Squash and Merge

Combines all commits into one:
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:
# .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:
1

Update Your Branch

git fetch origin
git checkout feature/new-feature
git merge origin/main
2

Resolve Conflicts

Edit conflicting files and resolve markers:
<<<<<<< HEAD
your changes
=======
incoming changes
>>>>>>> origin/main
3

Complete Merge

git add .
git commit -m "Resolve merge conflicts"
git push

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:
## 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

Keep PRs Small

Smaller PRs are easier to review and merge faster

Clear Descriptions

Explain what, why, and how of your changes

Link Issues

Reference related issues (Fixes #123)

Respond Promptly

Address review feedback quickly

See Also

Issues

Issue tracking and project management

Actions

CI/CD with Gitea Actions

Repositories

Repository management features

API Reference

Pull Request API endpoints

Build docs developers (and LLMs) love