Skip to content

Source Control

In Trae, you can use source control to manage changes to source code over time.

Activate Source Control

To start using source control in your project, follow these steps:

Step 1: Open Your Project

  1. Open your project in Trae

Step 2: Access Source Control Panel

  1. From the left navigation bar, select Source Control
  2. The Source Control panel appears

Step 3: Initialize Source Control

Based on your actual needs, activate source control using one of the following methods:

Option 1: Initialize Local Repository

If the currently opened folder does not have a Git repository:

  1. Click Initialize Repository to initialize a repository for it
  2. Once initialization is complete, source control will be enabled

Option 2: Publish to GitHub

  1. Click Publish to GitHub to directly publish this folder to a GitHub repository
  2. Once published, you will have access to source control

Use Source Control to Manage Your Code

You can use source control-related features, including commit, branches & tags, remotes, and more, to better manage your code.

Core Features

Trae's source control integration provides comprehensive Git functionality:

  • Commit Management: Stage, unstage, and commit changes with detailed commit messages
  • Branch Management: Create, switch, merge, and delete branches
  • Tag Management: Create and manage Git tags for version control
  • Remote Operations: Push, pull, fetch, and sync with remote repositories
  • Diff Viewing: Compare changes between different versions of files
  • Merge Conflict Resolution: Visual tools to resolve merge conflicts
  • History Browsing: View commit history and file changes over time

Working with Changes

The Source Control panel shows:

  • Changes: Files that have been modified but not yet staged
  • Staged Changes: Files ready to be committed
  • Merge Changes: Files with conflicts that need resolution

You can:

  • Stage individual files or all changes at once
  • Discard unwanted changes
  • View diffs for each modified file
  • Write descriptive commit messages

Use AI to Generate Git Commit Messages

A commit message is a summary of changes made to the repository's content. Each time you submit code, it's essential to provide an accurate Git commit message for identifying specific changes. In Trae, you can use AI to quickly summarize repository changes and generate a draft of Git commit message with just one click.

How to Use AI-Generated Commit Messages

  1. Make changes to your code and stage them in the Source Control panel
  2. In the commit message input field, look for the AI assistance option
  3. Click the AI generate button to automatically create a commit message based on your changes
  4. Review and edit the generated message as needed
  5. Commit your changes with the AI-generated or modified message

Benefits of AI-Generated Commit Messages

  • Consistency: Maintains a consistent format and style across commits
  • Accuracy: Analyzes actual code changes to create relevant descriptions
  • Time-saving: Eliminates the need to manually write commit messages
  • Best Practices: Follows Git commit message conventions automatically

Best Practices

When using source control in Trae:

  1. Commit Frequently: Make small, focused commits that represent logical units of work
  2. Write Clear Messages: Use descriptive commit messages that explain what and why
  3. Use Branches: Create feature branches for new development work
  4. Review Changes: Always review your changes before committing
  5. Sync Regularly: Pull changes from remote repositories frequently to avoid conflicts

Integration with Remote Development

Source control works seamlessly with Trae's remote development features:

  • WSL Integration: Full Git functionality when developing in WSL environments
  • SSH Remote: Complete source control access when working on remote hosts
  • Synchronized Experience: Consistent Git operations across local and remote environments

Your Ultimate AI-Powered IDE Learning Guide