Skip to content

Git Workflow

We use a dual-branch strategy to accommodate both Git and FTP workflows:

BranchPurposeUpdated By
mainDevelopment team changesManual commits
productionCoworker’s FTP changesAuto-commits every 15 min
graph LR
A[Coworker FTP] -->|Edits files| B[Production Server]
B -->|Auto-commit| C[production branch]
C -->|Pull request| D[main branch]
E[You - Local Dev] -->|git push| D
D -->|make deploy| B
  1. Work on main branch locally
  2. Push changes to GitHub
  3. Deploy to production with make deploy
  1. Edit files via FTP/ShiftEdit
  2. Cron job auto-commits every 15 minutes
  3. Changes pushed to production branch
  4. Team reviews via pull request
Terminal window
# See what coworker changed
make diff
# View recent auto-commits
make log
# Or open GitHub compare view
make compare

Open GitHub to see detailed changes:

Terminal window
# Open compare view in browser
open "https://github.com/my-marketing-pro/mmp-webapp/compare/main...production"

If coworker made changes you want to keep:

Option A: Via GitHub (Recommended)

  1. Go to GitHub
  2. Create pull request: productionmain
  3. Review changes
  4. Merge pull request

Option B: Via Command Line

Terminal window
# Fetch latest from production branch
git fetch origin production
# Merge into main
git checkout main
git merge origin/production
# Resolve any conflicts
git add .
git commit -m "Merge coworker changes from production"
git push
Terminal window
# Ensure you're on main
git checkout main
# Make changes
# ... edit files ...
# Commit
git add .
git commit -m "Your descriptive message"
# Push to GitHub
git push origin main
Terminal window
# Deploy main branch to production server
make deploy
# This runs:
# ssh mymarketingpro "cd /var/www/sftp/app &&
# sudo git stash &&
# sudo git checkout main &&
# sudo git pull &&
# sudo git stash pop"

A cron job on the production server runs every 15 minutes:

Terminal window
# Cron schedule
*/15 * * * * /usr/local/bin/auto-commit-mmp.sh >> /var/log/auto-commit.log 2>&1

File: /usr/local/bin/auto-commit-mmp.sh

#!/bin/bash
cd /var/www/sftp/app
git checkout production 2>/dev/null
git add -A
if ! git diff --staged --quiet; then
git commit -m "Auto-commit: $(date '+%Y-%m-%d %H:%M:%S')"
git push origin production
fi
  • Any file changes in /var/www/sftp/app/
  • Created by coworker via FTP
  • Committed with timestamp: Auto-commit: 2026-01-21 14:30:00
Terminal window
# SSH into server
ssh mymarketingpro
# View log
tail -f /var/log/auto-commit.log
# View recent commits
cd /var/www/sftp/app
git log --oneline -20
Terminal window
# Check coworker's changes vs your changes
make diff
# Check production server status
make status
# View recent auto-commits
make log
Terminal window
# Pull from main branch
make pull
# Pull from production branch (coworker changes)
make sync
Terminal window
# Deploy main branch to production
make deploy
Terminal window
# SSH into production server
make ssh
# Or directly
ssh mymarketingpro

If you and coworker edit the same file:

  1. Your changes are in main branch
  2. Coworker’s changes are in production branch
  3. Conflict occurs when merging

Resolution:

Terminal window
# Fetch coworker's changes
git fetch origin production
# Try to merge
git merge origin/production
# If conflict:
# 1. Open conflicted files
# 2. Look for conflict markers:
# <<<<<<< HEAD
# Your changes
# =======
# Coworker's changes
# >>>>>>> origin/production
# 3. Manually resolve
# 4. Stage and commit
git add .
git commit -m "Merge production: resolved conflicts"
git push

If something breaks after deployment:

Terminal window
# Check recent commits
git log --oneline -10
# Rollback to previous commit
git reset --hard <commit-hash>
# Force push (careful!)
git push origin main --force
# Redeploy
make deploy
Terminal window
# SSH into server
ssh mymarketingpro
# Check branch
cd /var/www/sftp/app
git branch --show-current

Should show: main (unless coworker is actively editing via FTP)

Terminal window
# Switch to main (for deployment)
sudo git checkout main
# Switch to production (for FTP access)
sudo git checkout production
Terminal window
# Before starting work
git pull origin main
# Make changes
# ...
# Push
git push origin main
Terminal window
# Check weekly
make log
# Or open GitHub
make compare

If making major changes, coordinate with coworker:

  • Let them know when you’ll deploy
  • Ask them to pause FTP edits during deployment
  • Review any pending changes first
Terminal window
# Bad
git commit -m "fixes"
# Good
git commit -m "Fix authentication redirect loop in app-auth.php:23"

5. Don’t Force Push to Production Branch

Section titled “5. Don’t Force Push to Production Branch”

The production branch is managed by auto-commits. Never:

Terminal window
# DON'T DO THIS
git push origin production --force

Let the cron job handle it.

Terminal window
# SSH into server
ssh mymarketingpro
# Check cron log
tail /var/log/auto-commit.log
# Check if script exists
ls -lh /usr/local/bin/auto-commit-mmp.sh
# Test script manually
sudo /usr/local/bin/auto-commit-mmp.sh
Terminal window
# On server
ssh mymarketingpro
cd /var/www/sftp/app
# Remove lock file
sudo rm -f .git/index.lock
# Try again
sudo git status
Terminal window
# On server, check ownership
ls -lh /var/www/sftp/app/.git/
# Should be owned by root or www-data
# If needed, fix permissions:
sudo chown -R www-data:www-data /var/www/sftp/app/.git/

Compare what changed between branches:

https://github.com/my-marketing-pro/mmp-webapp/compare/main...production

Create PR to merge productionmain:

https://github.com/my-marketing-pro/mmp-webapp/pull/new/production

See all auto-commits from coworker:

https://github.com/my-marketing-pro/mmp-webapp/commits/production