Files
newz-qwen-9b/docs/PUSH-CONFIG.md
T
Newzy Developer b34aef0b83 docs(push): configure push guidelines and requirements
- 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
2026-10-30 10:20:35 +00:00

202 lines
4.0 KiB
Markdown

# Push Configuration Guide
This document describes the configuration requirements for pushing to remote repositories.
## Remote Repository Setup
### Initial Setup
```bash
# 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
```bash
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
```bash
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:**
1. Linting (ESLint)
2. Test execution (optional, can be configured)
3. Commit message validation
**To configure the hook permanently:**
```bash
# 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:**
```bash
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`:
```yaml
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
```bash
# 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
```bash
# 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:**
```bash
# Fetch latest changes
git fetch origin
# Pull with rebase or merge
git pull --rebase origin <branch>
```
### Issue: Pre-push hook errors
**Solutions:**
1. Check if hooks are enabled: `git config core.hooksPath`
2. Verify hook permissions: `chmod +x .git/hooks/pre-push`
3. Install husky for proper hook management
---
*For push automation, use pull requests instead of direct pushes to main.*