Git Integration
Scoriet integrates with GitHub and GitLab, allowing you to automatically commit generated code to your repository. This enables version control and team collaboration on generated code.
Why Use Git Integration?
Git integration provides several benefits:
- Version Control - Track changes to generated code over time
- Collaboration - Team members see generation changes via Git history
- Automation - Commit generated code without manual Git operations
- Rollback - Revert to previous generated code if needed
- Code Review - Review generated code changes in pull requests
- Audit Trail - Complete history of what was generated and when
Supported Platforms
GitHub
- Public repositories
- Private repositories
- GitHub Enterprise
- GitHub.com and self-hosted GitHub
GitLab
- GitLab.com
- Self-hosted GitLab instances
- Public and private projects
Setting Up Git Integration
Step 1: Connect Your Account
- Open project Settings
- Go to Repository > Version Control
- Click Connect Repository button
- Choose GitHub or GitLab
- You're redirected to provider for authentication
- Grant permissions - Allow Scoriet to access repositories
- Confirm connection - Returns to Scoriet
git-connect-button.pngStep 2: Select Repository
After authentication:
- See list of your repositories
- Search for your repository by name
- Select the repository where generated code lives
- Choose branch:
- main/master - Primary branch
- develop - Development branch
- custom branch - Your specified branch
- Click Select Repository
Step 3: Configure Generation Settings
-
Choose commit options:
- Auto-commit on generate - Automatically commit when code is generated
- Manual commits - Generate code without committing, commit manually
- Commit on schedule - Commit generated changes at specific times
-
Set commit message template:
[Scoriet] Generated code from {:schema.name:} using {:template.name:}Available variables:
{:schema.name:}- Name of database schema{:template.name:}- Name of template used{:timestamp:}- Date/time of generation{:user.name:}- Person who generated- Custom text
-
Set commit author:
- Use Scoriet bot account
- Use your Git account
- Use team account
Use auto-commit during development to keep generated code synchronized. Disable during testing to avoid cluttering Git history.
Step 4: Configure File Paths
Specify where generated files are committed:
Base Directory: /app/generated/
Structure:
/api/ - API code
/models/ - Database models
/migrations/ - Database migrations
/tests/ - Test files
Pattern matching:
*.php- Only PHP filesapp/**/*.js- JavaScript in app directory-!config/**- Exclude config files
- Define directory structure
- Set which files to commit
- Exclude sensitive files (configs, credentials)
- Test patterns before committing
Never commit .env files, API keys, or passwords. Use pattern exclusions to prevent accidental credential commits.
Using Git Integration
Auto-Generating and Committing
When auto-commit is enabled:
- Generate code (click Generate or run template)
- Review generated output in preview
- Click Confirm Generate
- Files are committed automatically to selected branch
- See confirmation - "Committed to main on GitHub"
Manual Generation and Commits
When auto-commit is disabled:
- Generate code same as normal
- Files are saved locally
- Click Git > Commit Generated Code
- Review changes in commit dialog
- Enter commit message (or use template)
- Click Commit
Viewing Git History
See commit history from Scoriet:
- Go to project Settings
- Repository > Git History
- See recent commits from Scoriet
- Click commit to view files changed
- Inspect diffs between versions
git-history.pngPull and Sync
Keep your local and remote in sync:
- Settings > Repository > Sync
- Pull latest - Get remote changes
- Push pending - Send local commits
- Resolve conflicts - If changes conflict
Sync regularly when multiple people are generating code, especially if generating to the same branch.
Branch Management
Generating to Different Branches
Create separate branches for different purposes:
Development Branch:
- For testing new templates
- Frequent commits as you experiment
- No impact on main branch
Production Branch:
- For stable, released code
- Less frequent generation
- Careful review before committing
Switching Branches
- Settings > Repository > Select Branch
- Choose different branch
- Next generation commits to new branch
Creating New Branches
- Settings > Repository
- Click Create Branch
- Name new branch (e.g., "feature/new-api")
- Creates branch from current (usually main)
- Automatically switches to new branch
Use descriptive branch names: feature/customer-api, feature/admin-templates, fix/migration-bug
Merge Requests and Pull Requests
Automatic PR Creation
When generating to a feature branch:
- Generate code to feature branch
- Click Create Pull Request
- Set PR details:
- Title: "Generated code for customer API"
- Description: Auto-populated with generation details
- Reviewers: Assign team members
- Create PR - Ready for review
Reviewing Generated Code
Team members review PRs:
- See generated changes in Files Changed tab
- Comment on code - Questions, suggestions
- Request changes - If adjustments needed
- Approve - When satisfied
- Merge to main - After approval
This workflow ensures generated code is reviewed before reaching production.
Handling Conflicts
When Conflicts Occur
If manual changes and generated code conflict:
- Scoriet detects conflict when pulling
- Shows conflict resolution dialog
- Choose resolution strategy:
- Keep generated (overwrite manual changes)
- Keep manual (ignore generated changes)
- Merge (combine both)
Preventing Conflicts
Best practices to minimize conflicts:
-
Separate generated and manual code
/generated/ - Only code from Scoriet/src/ - Manual code and overrides/config/ - Configuration (don't generate) -
Use include patterns - Only commit specific files
-
Exclude common conflict areas - Don't generate config files
-
Coordinate with team - Who's generating when?
-
Review before merging - Catch conflicts early
If conflicts occur frequently, review your file organization. Better separation of generated and manual code prevents conflicts.
Advanced Git Integration
GitHub Actions Integration
Trigger GitHub Actions when code is generated:
- Settings > Repository > GitHub Actions
- Select workflows to trigger
- When generation occurs, workflow runs automatically
- Example: Run tests, build project, deploy
name: On Scoriet Generation
on:
push:
paths:
- 'generated/**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Tests
run: npm test
GitLab CI/CD Integration
Similar to GitHub Actions for GitLab:
- Settings > Repository > GitLab CI
- Enable pipeline triggers
- Configure .gitlab-ci.yml for Scoriet commits
- Pipelines run automatically on generation
Webhook Notifications
Send notifications when code is generated:
- Settings > Repository > Webhooks
- Add webhook URL (Slack, Discord, etc.)
- Choose trigger events:
- Code generated
- PR created
- Merge completed
- Receive notifications in your chat
Example Slack message:
John generated code from customers schema using Laravel Migration template
Branch: feature/customer-api
Files: 3 changed, 42 insertions, 5 deletions
Troubleshooting Git Integration
Authentication Failed
Solutions:
- Reconnect account - Settings > Repository > Reconnect
- Check token expiration - Some tokens expire after 30 days
- Verify permissions - Does account have repo access?
- Try personal token - Use Personal Access Token instead of OAuth
Commits Not Appearing
Check these:
- Auto-commit enabled? - Settings > Repository > Auto-commit
- Correct branch selected? - Verify in Settings > Repository
- Files excluded? - Check pattern exclusions
- Check Git history - Settings > Repository > History
Merge Conflicts
Prevention:
- Keep generated and manual code separate
- Use file pattern exclusions
- Coordinate generation times with team
- Pull changes before generating
Resolution:
- Pull latest from remote
- Manually resolve conflicts in editor
- Test changes locally
- Commit resolved state
Permission Errors
Ensure account has:
- ✓ Write access to repository
- ✓ Ability to create branches
- ✓ Ability to create pull requests
- ✓ Admin access for webhook setup
Ask repository owner to grant permissions.
Git Integration Best Practices
Workflow Recommendations
Recommended workflow:
1. Create feature branch for generation task
2. Generate code to feature branch
3. Create pull request automatically
4. Team reviews generated code
5. Make adjustments if needed
6. Merge to develop after approval
7. Deploy develop to staging
8. Test and validate
9. Merge to main/production
Commit Message Standards
Use clear, consistent commit messages:
✓ [Scoriet] Generated API models from customers schema
✓ Generated migration for product_reviews table
✓ Updated Laravel seeder from latest database
✗ update files
✗ fix
✗ changes
Handling Generated Code
Treat generated code as read-only:
/generated/ ← Pure generated code, don't edit
/src/models/ ← Manual customizations of models
/overrides/ ← Overrides and extensions
Coordination with Team
When generating in shared repository:
- Announce generation - Let team know you're generating
- Use feature branches - Don't commit to main
- Create PR first - Let team review before merging
- Avoid conflicts - Don't generate while others are working
- Update documentation - Note what changed
Regular Reviews
Periodically review Git integration:
- ✓ Are commits meaningful and clear?
- ✓ Is file structure still appropriate?
- ✓ Are excluded patterns still correct?
- ✓ Is auto-commit helping or causing issues?
- ✓ Do team members understand the workflow?
Disconnecting Git Integration
If you want to stop using Git integration:
- Settings > Repository > Disconnect
- Confirm disconnection
- Generated code stays in repository
- Scoriet stops making commits
- Can reconnect anytime
Disconnecting doesn't affect your repository. All previous commits remain in Git history.
Related Topics: