- Document remote repository setup procedures - Outline branch protection rules for main and develop - Add troubleshooting guide for common push issues - Provide examples for feature and hotfix workflows
4.0 KiB
4.0 KiB
Push Configuration Guide
This document describes the configuration requirements for pushing to remote repositories.
Remote Repository Setup
Initial Setup
# Add remote repository
git remote add origin <repository-url>
# Verify remote
git remote -v
Recommended Remotes
- origin - Primary production remote (main branch)
- develop - Optional secondary remote for development branches
Push Guidelines
Pushing to Main (Production)
Requirements:
- Pull request merged from approved branch
- All automated tests passing
- Code review complete
- Maintainer approval obtained
git checkout main
git pull origin main --rebase
git push origin main
Pushing to Develop
Requirements:
- Feature/bugfix branches merged from source branch
- Automated CI/CD checks passed
- At least one code reviewer approval
git checkout develop
git pull origin develop --rebase
git merge <feature-branch> # if not using rebase flow
git push origin develop
Pre-Push Hook Configuration
The project uses a pre-push hook to validate code before pushing:
What it checks:
- Linting (ESLint)
- Test execution (optional, can be configured)
- Commit message validation
To configure the hook permanently:
# Install husky globally or in package.json
npm install --save-dev husky
npx husky install
npx husky add .git/hooks/pre-push 'npm run lint'
To update existing hooks:
git config core.hooksPath .githooks
chmod +x .githooks/pre-push
Branch Protection Rules (on remote)
Main Branch Protection
- ✅ Require pull request reviews before merging
- ✅ Require status checks to pass before merging
- ✅ Require branches to be up to date before merging
- ❌ Prevent direct commits to main
- ❌ Restrict who can push to main
Develop Branch Rules
- ✅ Require signed-off commits
- ⚠️ Allow force push by maintainers only
- ⚠️ Enable branch auto-merge for approved PRs
CI/CD Integration
GitHub Actions (Recommended)
Create .github/workflows/push.yml:
name: Pre-Push Validation
on:
push:
branches: [main, develop]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint --if-present
- name: Run tests
run: npm test --if-present
Push Configuration Examples
For Feature Development
# Create feature branch from develop
git checkout develop
git pull origin develop
git checkout -b feature/my-feature-name
# Work on your feature...
git add .
git commit -m "feat: implement new feature"
# Test locally before pushing
npm test
npm run lint
# Push to origin
git push origin feature/my-feature-name
For Hotfix Deployment
# Create hotfix from main
git checkout main
git pull origin main
git checkout -b hotfix/critical-fix
# Fix the issue...
git add .
git commit -m "fix: resolve critical production bug"
# Push to both main and develop
git push origin hotfix/critical-fix
# Merge to main (fast-forward preferred for hotfixes)
git checkout main
git merge --no-ff hotfix/critical-fix
git push origin main
# Merge to develop
git checkout develop
git merge --no-ff hotfix/critical-fix
git push origin develop
Push Troubleshooting
Issue: Cannot push to protected branch
Solution: Ensure all requirements are met and create/await PR approval.
Issue: Non-fast-forward update
Solution:
# Fetch latest changes
git fetch origin
# Pull with rebase or merge
git pull --rebase origin <branch>
Issue: Pre-push hook errors
Solutions:
- Check if hooks are enabled:
git config core.hooksPath - Verify hook permissions:
chmod +x .git/hooks/pre-push - Install husky for proper hook management
For push automation, use pull requests instead of direct pushes to main.