You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

多设备Drupal网站开发协作工作流优化问题咨询

Optimal Drupal Development Workflow with Self-Hosted GOGS Across Two Devices

Hey there! As someone who’s juggled Drupal development across multiple machines with private repos, I’ve got a solid workflow to share that’ll keep your work consistent, secure, and hassle-free. Let’s dive in:

1. First: Lock Down Your GOGS & Git Setup

Before diving into daily work, make sure both devices are properly configured to interact with your GOGS repo:

  • SSH Keys for Passwordless Access: Generate an SSH key on each device with ssh-keygen -t ed25519 -C "your-email@example.com", then add the public key (~/.ssh/id_ed25519.pub) to your GOGS account settings. This eliminates typing passwords every time you push/pull.
  • Project Gitignore: Create a .gitignore file in your Drupal root and add these critical entries to avoid syncing local-only files:
    sites/default/files/
    sites/default/settings.local.php
    vendor/
    *.sql
    .env
    
    Note: Keep composer.lock in Git—this ensures both devices install identical dependency versions.

2. Daily Development Workflow (Cross-Device Friendly)

The key here is to avoid working directly on your main branch and use feature branches for all changes. Here’s how to bounce between laptop and desktop smoothly:

Scenario 1: Starting Work on One Device

  • Pull the latest stable code from GOGS: git pull origin main
  • Create a dedicated feature branch: git checkout -b feature/add-contact-form-validation
  • Code away! Commit frequently with clear messages: git commit -m "Add server-side validation for contact form fields"
  • Push the branch to GOGS when you’re ready to switch devices: git push origin feature/add-contact-form-validation

Scenario 2: Switching to the Other Device

  • Fetch all remote branches: git fetch origin
  • Check out your feature branch: git checkout feature/add-contact-form-validation
  • Pull any new commits you pushed earlier: git pull origin feature/add-contact-form-validation
  • Resume coding—no lost work, no messy conflicts (yet!)

Handling WIP (Work in Progress) Code

If you need to switch mid-task without finishing a commit:

  • Stash your changes temporarily: git stash push -m "WIP: Half-finished AJAX submission logic"
  • On the other device, retrieve the stash: git stash apply
  • Alternatively, commit a WIP change: git commit -m "WIP: Start AJAX submission work"—push it to GOGS, then on the other device, use git reset HEAD~1 to undo the commit and return to your uncommitted state. This is safer than stashes if you’re worried about losing work.

3. Drupal-Specific Optimizations

Drupal has unique quirks—here’s how to keep your local environments in sync:

  • Local Configuration Separation: Each device should have its own settings.local.php (ignored by Git) with database credentials, debug mode settings, and local caching configs. Add this line to your main settings.php to load the local file automatically:
    if (file_exists(__DIR__ . '/settings.local.php')) {
      include __DIR__ . '/settings.local.php';
    }
    
  • Database Sync: When you need to move your Drupal database between devices:
    • On the source device, dump the DB with Drush: drush sql-dump --result-file=drupal-db.sql
    • Transfer the .sql file to the target device (use scp, a USB drive, or a private file sync tool—avoid committing large SQL files to Git!)
    • On the target device, import with Drush: drush sql-drop && drush sql-cli < drupal-db.sql
    • For a faster workflow, set up Drush site aliases so you can run drush sql-sync @laptop @desktop directly (if devices can reach each other over your network).
  • Composer Dependency Consistency: Always run composer install (not composer update) on both devices to install exact versions from composer.lock. If you need to update dependencies, do it on one device, commit the updated composer.lock, then pull and run composer install on the other.

4. Branch & Repo Maintenance

  • Keep your main branch stable: Only merge feature branches into main after testing them thoroughly on one device first.
  • Use GOGS Pull Requests (if available): Even though you’re working alone, PRs let you review your own code, leave notes, and keep a clean commit history. Merge the PR to main once you’re satisfied.
  • Clean up old branches: Once a feature is merged, delete the branch locally (git branch -d feature/old-branch) and remotely (git push origin --delete feature/old-branch) to keep your repo tidy.

5. Troubleshooting Common Issues

  • Merge Conflicts: If you accidentally work on the same file across devices, use git diff to see the conflict, resolve it manually, then commit the fix. For Drupal config files (in config/sync), double-check that you’re not overriding active config changes.
  • Dependency Mismatches: If one device has missing packages, delete the vendor folder, run git checkout composer.lock, then composer install to reset dependencies.
  • GOGS Sync Errors: If pushes/pulls fail, verify your SSH key is still active in GOGS, and that your device has network access to the VPS hosting GOGS.

内容的提问来源于stack exchange,提问作者woxene

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:13:00