Some checks failed
CD - Build & Deploy / build-and-push (push) Has been cancelled
CD - Build & Deploy / package-helm (push) Has been cancelled
CD - Build & Deploy / deploy-staging (push) Has been cancelled
CD - Build & Deploy / deploy-production (push) Has been cancelled
CD - Build & Deploy / release (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / security (push) Has been cancelled
- Implemented Clean Architecture with Domain, Application, Infrastructure, Presentation layers - Added comprehensive project structure following SOLID principles - Created Kubernetes deployment with Helm charts (HPA, PDB, NetworkPolicy) - Configured ArgoCD for automated deployment (production + staging) - Implemented CI/CD pipeline with GitHub Actions - Added comprehensive documentation (handbook, architecture, coding standards) - Configured PostgreSQL, Redis, Celery for backend services - Created modern landing page with Persian fonts (Vazirmatn) - Added Docker multi-stage build for production - Configured development tools (pytest, black, flake8, mypy, isort) - Added pre-commit hooks for code quality - Implemented Makefile for common operations
6.8 KiB
6.8 KiB
Git Workflow
Branch Strategy
Main Branches
main (production)
└── develop (staging)
- main: Production-ready code
- develop: Integration branch for features
Supporting Branches
develop
├── feature/user-authentication
├── feature/billing-system
├── bugfix/payment-timeout
└── hotfix/security-patch
Branch Naming Convention
Feature Branches
feature/short-description
feature/user-auth
feature/payment-gateway
Bugfix Branches
bugfix/issue-description
bugfix/payment-timeout
bugfix/email-sending
Hotfix Branches
hotfix/critical-issue
hotfix/security-vuln
hotfix/data-loss
Commit Message Format
Structure
<type>(<scope>): <subject>
<body>
<footer>
Type
feat: ویژگی جدیدfix: رفع باگdocs: تغییرات مستنداتstyle: فرمتبندی، فاصلهگذاریrefactor: بازنویسی کدperf: بهبود performancetest: اضافه/اصلاح تستchore: کارهای نگهداریbuild: تغییرات build systemci: تغییرات CI/CD
Scope
بخشی از کد که تغییر کرده:
authbillingapidatabaseui
Examples
feat(auth): add two-factor authentication
- Implement TOTP-based 2FA
- Add QR code generation
- Add backup codes
Closes #123
fix(payment): resolve timeout issue with zarinpal
The payment gateway was timing out due to long response time.
Added retry logic with exponential backoff.
Fixes #456
docs(api): update authentication endpoints
Added examples for JWT token usage and refresh flow.
Workflow Steps
1. شروع کار روی Feature جدید
# بروزرسانی develop
git checkout develop
git pull origin develop
# ایجاد branch جدید
git checkout -b feature/my-feature
# شروع کدنویسی...
2. Commit های منظم
# بررسی تغییرات
git status
git diff
# Stage کردن
git add src/specific/file.py
# یا
git add .
# Commit
git commit -m "feat(scope): description"
# Push (اولین بار)
git push -u origin feature/my-feature
# Push های بعدی
git push
3. نگهداری Branch بهروز
# بروزرسانی از develop
git checkout develop
git pull origin develop
git checkout feature/my-feature
git merge develop
# حل conflict ها (در صورت وجود)
# ... edit files ...
git add .
git commit -m "merge: resolve conflicts with develop"
4. ایجاد Pull Request
- Push کردن همه commits
- رفتن به GitHub/GitLab
- Create Pull Request
- انتخاب base:
develop, compare:feature/my-feature - عنوان و توضیحات
- Request reviewers
- Link کردن issues
5. Code Review Process
برای نویسنده:
- پاسخ به comments
- انجام تغییرات درخواستی
- Push کردن updates
- Request re-review
برای Reviewer:
- بررسی کد با دقت
- Check کردن tests
- بررسی code quality
- Approve یا Request Changes
6. Merge
پس از approval:
# Squash and Merge (توصیه میشود)
# یا
# Merge Commit
# یا
# Rebase and Merge
7. پاک کردن Branch
# Local
git branch -d feature/my-feature
# Remote (معمولا automatic)
git push origin --delete feature/my-feature
Best Practices
Commit های کوچک و مشخص
# ✅ GOOD: Small, focused commits
git commit -m "feat(auth): add email validation"
git commit -m "test(auth): add tests for email validation"
git commit -m "docs(auth): document email validation"
# ❌ BAD: Large, vague commit
git commit -m "add stuff"
Commit منظم
# Commit هر چند ساعت یکبار
# نه خیلی کم (هر خط کد)
# نه خیلی زیاد (روزی یک commit)
Push روزانه
# حداقل یکبار در روز push کنید
# از دست رفتن کد جلوگیری میکند
استفاده از .gitignore
# اضافه نکردن فایلهای غیرضروری
# - __pycache__
# - .env
# - venv/
# - *.pyc
Git Commands Reference
Basic
# Status
git status
# Log
git log
git log --oneline
git log --graph
# Diff
git diff
git diff --staged
Branching
# لیست branches
git branch
git branch -a # با remote
# ایجاد branch
git branch feature/new-feature
git checkout -b feature/new-feature # ایجاد + checkout
# تغییر branch
git checkout develop
# حذف branch
git branch -d feature/old-feature
git branch -D feature/force-delete # Force
Stashing
# ذخیره تغییرات موقت
git stash
# با پیام
git stash save "work in progress"
# لیست stash ها
git stash list
# برگرداندن stash
git stash apply
git stash pop # apply + delete
# حذف stash
git stash drop
git stash clear # همه
Undoing Changes
# Unstage file
git reset HEAD file.py
# Discard changes
git checkout -- file.py
# Undo last commit (keep changes)
git reset --soft HEAD~1
# Undo last commit (discard changes)
git reset --hard HEAD~1
# Revert commit (safe)
git revert <commit-hash>
Rebasing
# Rebase on develop
git checkout feature/my-feature
git rebase develop
# Interactive rebase
git rebase -i HEAD~3 # آخرین 3 commits
# Abort rebase
git rebase --abort
# Continue after resolving conflicts
git rebase --continue
Tags
# ایجاد tag
git tag v1.0.0
# با پیام
git tag -a v1.0.0 -m "Release version 1.0.0"
# Push tags
git push origin v1.0.0
git push origin --tags # همه tags
# حذف tag
git tag -d v1.0.0
git push origin --delete v1.0.0
Merge Conflicts
حل Conflict
# 1. مشاهده conflicts
git status
# 2. باز کردن فایل و حل conflict
# <<<<<<< HEAD
# کد شما
# =======
# کد دیگران
# >>>>>>> branch-name
# 3. Stage کردن
git add resolved-file.py
# 4. Commit
git commit -m "merge: resolve conflicts"
ابزارهای کمکی
# استفاده از merge tool
git mergetool
# استفاده از --ours یا --theirs
git checkout --ours file.py
git checkout --theirs file.py
Tips & Tricks
Aliases
# در ~/.gitconfig
[alias]
co = checkout
br = branch
ci = commit
st = status
lg = log --oneline --graph --decorate
Commit Templates
# در ~/.gitmessage
<type>(<scope>): <subject>
<body>
<footer>
git config --global commit.template ~/.gitmessage
Auto-completion
# Bash
source /usr/share/bash-completion/completions/git
# Zsh
autoload -Uz compinit && compinit
مهم: این workflow الزامی است و در code review بررسی میشود.