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
- Open your project in Trae
Step 2: Access Source Control Panel
- From the left navigation bar, select Source Control
- 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:
- Click Initialize Repository to initialize a repository for it
- Once initialization is complete, source control will be enabled
Option 2: Publish to GitHub
- Click Publish to GitHub to directly publish this folder to a GitHub repository
- 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
- Make changes to your code and stage them in the Source Control panel
- In the commit message input field, look for the AI assistance option
- Click the AI generate button to automatically create a commit message based on your changes
- Review and edit the generated message as needed
- 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:
- Commit Frequently: Make small, focused commits that represent logical units of work
- Write Clear Messages: Use descriptive commit messages that explain what and why
- Use Branches: Create feature branches for new development work
- Review Changes: Always review your changes before committing
- 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