# Git Flow სრულყოფილი დოკუმენტაცია ## შინაარსი 1. [Git Flow-ის შესავალი](#git-flow-ის-შესავალი) 2. [ძირითადი კონცეპტები](#ძირითადი-კონცეპტები) 3. [ინსტალაცია და კონფიგურაცია](#ინსტალაცია-და-კონფიგურაცია) 4. [ბრენჩების სტრუქტურა](#ბრენჩების-სტრუქტურა) 5. [Git Flow ყოველდღიური მუშაობა](#git-flow-ყოველდღიური-მუშაობა) 6. [პრაქტიკული მაგალითები](#პრაქტიკული-მაგალითები) 7. [საუკეთესო პრაქტიკები](#საუკეთესო-პრაქტიკები) 8. [ხშირი შეცდომები](#ხშირი-შეცდომები) 9. [ალტერნატივები](#ალტერნატივები) 10. [ჩვენი გუნდისთვის რეკომენდაციები](#ჩვენი-გუნდისთვის-რეკომენდაციები) --- ## Git Flow-ის შესავალი Git Flow არის ბრენჩინგ მოდელი, რომელიც Vincent Driessen-მა 2010 წელს შეიმუშავა. ეს მოდელი განკუთვნილია საშუალო და დიდი გუნდებისთვის, რომლებსაც სჭირდებათ: - **სტრუქტურირებული განვითარება** - ნათელი წესები რა როგორ უნდა განვითარდეს - **პარალელური მუშაობა** - რამდენიმე ფუნქცია ერთდროულად - **სტაბილური რელიზები** - პროდუქციული ვერსიების უსაფრთხო გაშვება - **სწრაფი ჰოთფიქსები** - კრიტიკული ბაგების სწრაფი ამოვარდნა ### რატომ Git Flow? **ტრადიციული Git მუშაობის პრობლემები:** - ბრენჩების ქაოსი - რელიზების რთული მენეჯმენტი - კოდის ხარისხის კონტროლის სირთულე - გუნდის წევრების კოორდინაციის პრობლემები **Git Flow-ის გადაწყვეტილებები:** - ყველასთვის ნათელი წესები - ავტომატიზებული პროცესები - რისკების მინიმიზაცია - ეფექტური კოლაბორაცია --- ## ძირითადი კონცეპტები ### ბრენჩების იერარქია ``` main/master ←── მუდმივად სტაბილური პროდუქცია ↑ develop ←── განვითარების მთავარი ხაზი ↑ ↑ feature/xyz hotfix/abc feature/abc ``` ### ცხოვრების ციკლი 1. **Feature Development** - ახალი ფუნქციების განვითარება 2. **Integration** - ფუნქციების develop-ში ინტეგრაცია 3. **Release Preparation** - რელიზის მომზადება 4. **Production Release** - პროდუქციაში გაშვება 5. **Hotfix** - კრიტიკული ფიქსები --- ## ინსტალაცია და კონფიგურაცია ### Git Flow Tools ინსტალაცია #### macOS ```bash # Homebrew-ით brew install git-flow # MacPorts-ით sudo port install git-flow ``` #### Ubuntu/Debian ```bash sudo apt-get install git-flow ``` #### Windows ```bash # Git for Windows-ით მოდის # ან Chocolatey-ით choco install gitflow-avh ``` ### Git Flow ინიციალიზაცია ```bash # არსებული რეპოზიტორიაში cd your-project git flow init # ახალი პროექტისთვის git clone https://github.com/hackem/project.git cd project git flow init ``` ### ინიციალიზაციის კონფიგურაცია ```bash $ git flow init Which branch should be used for bringing forth production releases? - main Branch name for production releases: [main] Which branch should be used for integration of the "next release"? - develop Branch name for "next release" development: [develop] How to name your supporting branch prefixes? Feature branches? [feature/] Bugfix branches? [bugfix/] Release branches? [release/] Hotfix branches? [hotfix/] Support branches? [support/] Version tag prefix? [] ``` ### ჩვენი გუნდისთვის რეკომენდებული კონფიგურაცია ```bash # .gitflow კონფიგურაცია [gitflow "branch"] master = main develop = develop [gitflow "prefix"] feature = feature/ bugfix = bugfix/ release = release/ hotfix = hotfix/ support = support/ versiontag = v ``` --- ## ბრენჩების სტრუქტურა ### 1. Main/Master ბრენჩი **მიზანი:** პროდუქციული, სტაბილური კოდი ```bash # Main branch მახასიათებლები: - ყოველთვის deployable - არასდროს პირდაპირ კომიტი - ყველა commit tag-ით მონიშნული - CI/CD pipeline-ში ავტომატური deployment ``` **წესები:** - მხოლოდ release და hotfix ბრენჩებიდან merge - ყველა merge-ზე version tag - Protected branch GitHub/GitLab-ში ### 2. Develop ბრენჩი **მიზანი:** განვითარების ინტეგრაციის ხაზი ```bash # Develop branch-ზე მუშაობა git checkout develop git pull origin develop # ასპუბლიკება git push origin develop ``` **მახასიათებლები:** - ყველა feature აქ მერჯება - ყოველთვის feature-complete - ნაკლებად სტაბილური main-ზე - Pre-production environment-ში deployment ### 3. Feature ბრენჩები **სტრუქტურა:** `feature/JIRA-123-user-authentication` ```bash # Feature branch-ის შექმნა git flow feature start JIRA-123-user-authentication # ან ხელით git checkout develop git checkout -b feature/JIRA-123-user-authentication ``` **სახელების კონვენცია:** ```bash feature/JIRA-123-user-authentication feature/TASK-456-email-notifications feature/STORY-789-dashboard-redesign feature/BUG-101-login-fix ``` **Feature განვითარების პროცესი:** ```bash # 1. Feature-ის დაწყება git flow feature start user-authentication # 2. მუშაობა git add . git commit -m "feat: implement login functionality" git commit -m "feat: add password validation" git commit -m "test: add authentication tests" # 3. Remote-ში push (თანამშრომლობისთვის) git push origin feature/user-authentication # 4. Feature-ის დასრულება git flow feature finish user-authentication ``` ### 4. Release ბრენჩები **სტრუქტურა:** `release/v1.2.0` ```bash # Release-ის დაწყება git flow release start v1.2.0 # ან ხელით git checkout develop git checkout -b release/v1.2.0 ``` **Release მომზადების ტასკები:** ```bash # 1. ვერსიის განახლება echo "1.2.0" > VERSION npm version 1.2.0 git commit -m "bump version to 1.2.0" # 2. CHANGELOG.md განახლება git add CHANGELOG.md git commit -m "docs: update changelog for v1.2.0" # 3. Documentation განახლება git add README.md docs/ git commit -m "docs: update documentation for v1.2.0" # 4. ბაგფიქსები (მხოლოდ!) git commit -m "fix: resolve minor UI issues" git commit -m "fix: correct API response format" ``` **Release დასრულება:** ```bash git flow release finish v1.2.0 ``` ეს ავტომატურად: - Merge main-ში - Tag v1.2.0 შექმნა - Merge develop-ში - Release branch-ის წაშლა ### 5. Hotfix ბრენჩები **სტრუქტურა:** `hotfix/v1.1.1-security-fix` ```bash # Hotfix-ის დაწყება git flow hotfix start v1.1.1-security-fix # ან ხელით git checkout main git checkout -b hotfix/v1.1.1-security-fix ``` **Hotfix მაგალითი:** ```bash # 1. Hotfix-ის დაწყება git flow hotfix start v1.1.1 # 2. კრიტიკული ბაგის ფიქსი git commit -m "fix: resolve critical security vulnerability" git commit -m "fix: update dependencies" # 3. ვერსიის განახლება echo "1.1.1" > VERSION git commit -m "bump version to 1.1.1" # 4. Hotfix-ის დასრულება git flow hotfix finish v1.1.1 ``` --- ## Git Flow ყოველდღიური მუშაობა ### დილის რუტინა ```bash # 1. ყველა branch-ის განახლება git checkout main git pull origin main git checkout develop git pull origin develop # 2. ხორცი feature-ის შექმნა git flow feature start TASK-123-new-feature # 3. მუშაობის დაწყება code . ``` ### კომიტების წესები ```bash # Conventional Commits Format git commit -m "feat: add user authentication" git commit -m "fix: resolve login redirect issue" git commit -m "docs: update API documentation" git commit -m "test: add unit tests for auth module" git commit -m "refactor: improve code structure" ``` ### კომიტის ტიპები: - **feat:** ახალი ფუნქცია - **fix:** ბაგფიქსი - **docs:** დოკუმენტაცია - **test:** ტესტები - **refactor:** კოდის რეფაქტორინგი - **style:** კოდის სტილი - **chore:** პროექტის მოვლა ### Feature-ის Pull Request პროცესი ```bash # 1. Feature-ის remote-ში push git push origin feature/TASK-123-new-feature # 2. GitHub/GitLab-ში Pull Request შექმნა # Title: [TASK-123] Add user authentication feature # Description: # - Implements login/logout functionality # - Adds JWT token management # - Includes unit tests # - Updates API documentation # 3. Code Review მოთხოვნა # Reviewers: @john-doe, @jane-smith # Labels: feature, needs-review # 4. CI/CD checks-ის მოლოდინი # - Unit tests pass # - Integration tests pass # - Code quality check pass # - Security scan pass # 5. Approval-ის მიღება # - Minimum 2 approvals required # - All comments resolved # - All checks passed # 6. Merge to develop git checkout develop git pull origin develop git flow feature finish TASK-123-new-feature ``` --- ## პრაქტიკული მაგალითები ### სცენარი 1: ახალი ფუნქციის დამატება ```bash # ტექნიკური ტასკი: User Profile Management # 1. Feature-ის დაწყება git flow feature start user-profile-management # 2. განვითარების ეტაპები git add components/UserProfile.js git commit -m "feat: create user profile component" git add api/profile.js git commit -m "feat: implement profile API endpoints" git add __tests__/profile.test.js git commit -m "test: add profile component tests" git add docs/api/profile.md git commit -m "docs: add profile API documentation" # 3. Code Review-ისთვის მომზადება git push origin feature/user-profile-management # 4. PR დასრულების შემდეგ git checkout develop git pull origin develop git flow feature finish user-profile-management ``` ### სცენარი 2: რელიზის მომზადება ```bash # კვარტლის რელიზი: v2.1.0 # 1. Release-ის დაწყება git checkout develop git pull origin develop git flow release start v2.1.0 # 2. ვერსიის მომზადება # package.json-ში version განახლება npm version 2.1.0 --no-git-tag-version git add package.json package-lock.json git commit -m "bump version to 2.1.0" # 3. CHANGELOG.md შექმნა cat << 'EOF' > CHANGELOG.md # Changelog ## [2.1.0] - 2024-01-15 ### Added - User profile management system - Email notification preferences - Dashboard customization options - Advanced search functionality ### Changed - Improved UI/UX for mobile devices - Enhanced API response performance - Updated authentication flow ### Fixed - Login redirect issue - Profile image upload bug - Dashboard loading performance - Mobile responsiveness issues ### Security - Updated dependencies - Enhanced password validation - Added rate limiting EOF git add CHANGELOG.md git commit -m "docs: add changelog for v2.1.0" # 4. Documentation განახლება git add README.md docs/ git commit -m "docs: update documentation for v2.1.0" # 5. ბოლო წუთის ბაგფიქსები git commit -m "fix: resolve minor UI alignment issues" git commit -m "fix: correct API response format" # 6. Release-ის დასრულება git flow release finish v2.1.0 # ავტომატურად შეიქმნება v2.1.0 tag # 7. Remote-ში push git push origin main git push origin develop git push origin --tags ``` ### სცენარი 3: კრიტიკული ბაგის ფიქსი ```bash # პროდუქციაში აღმოჩენილი კრიტიკული ბაგი # 1. Hotfix-ის დაწყება git checkout main git pull origin main git flow hotfix start v2.0.1 # 2. ბაგის ფიქსი git add src/auth/login.js git commit -m "fix: resolve critical login vulnerability" git add __tests__/auth.test.js git commit -m "test: add tests for login security fix" # 3. ვერსიის განახლება npm version 2.0.1 --no-git-tag-version git add package.json package-lock.json git commit -m "bump version to 2.0.1" # 4. CHANGELOG განახლება cat << 'EOF' >> CHANGELOG.md ## [2.0.1] - 2024-01-16 ### Security - Fixed critical authentication vulnerability - Enhanced input validation EOF git add CHANGELOG.md git commit -m "docs: add changelog for v2.0.1" # 5. Hotfix-ის დასრულება git flow hotfix finish v2.0.1 # 6. Remote-ში push git push origin main git push origin develop git push origin --tags # 7. Production deployment # CI/CD pipeline ავტომატურად deploy-ს v2.0.1 tag-ს ``` --- ## საუკეთესო პრაქტიკები ### 1. Branch სახელების კონვენცია ```bash # ✅ კარგი მაგალითები feature/JIRA-123-user-authentication feature/TASK-456-email-notifications feature/STORY-789-dashboard-redesign bugfix/BUG-101-login-redirect hotfix/v1.2.3-security-patch release/v2.1.0 # ❌ ცუდი მაგალითები feature/authentication bugfix/fix hotfix/urgent release/next ``` ### 2. კომიტის მესიჯები ```bash # ✅ კარგი მაგალითები feat: add user authentication system fix: resolve login redirect issue after password reset docs: update API documentation for user endpoints test: add unit tests for authentication module refactor: improve error handling in auth service # ❌ ცუდი მაგალითები fixed bug updated code working on auth commit asdf ``` ### 3. Pull Request ტემპლეითი ```markdown ## Description Brief description of changes made ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Breaking change - [ ] Documentation update - [ ] Refactoring ## Testing - [ ] Unit tests added/updated - [ ] Integration tests added/updated - [ ] Manual testing completed - [ ] All tests pass ## Checklist - [ ] Code follows style guidelines - [ ] Self-review completed - [ ] Documentation updated - [ ] No breaking changes (or documented) - [ ] Related issues linked ## Screenshots/Videos If applicable, add screenshots or videos ## Related Issues Closes #123 Fixes #456 ``` ### 4. CI/CD ინტეგრაცია ```yaml # .github/workflows/git-flow.yml name: Git Flow CI/CD on: push: branches: [ main, develop ] tags: [ 'v*' ] pull_request: branches: [ develop ] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '18' - name: Install dependencies run: npm ci - name: Run tests run: npm test - name: Run linting run: npm run lint deploy-staging: if: github.ref == 'refs/heads/develop' needs: test runs-on: ubuntu-latest steps: - name: Deploy to staging run: echo "Deploying to staging environment" deploy-production: if: startsWith(github.ref, 'refs/tags/v') needs: test runs-on: ubuntu-latest steps: - name: Deploy to production run: echo "Deploying to production environment" ``` ### 5. Branch Protection Rules ```bash # GitHub-ში main და develop branch-ებისთვის: 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 - Require signed commits - Restrict pushes that create files larger than 100MB - Allow only merge commits Develop Branch Protection: - Require pull request reviews before merging - Require status checks to pass before merging - Allow squash merging - Allow merge commits - Allow rebase merging ``` --- ## ხშირი შეცდომები ### 1. Feature Branch-ზე პირდაპირ მუშაობა ```bash # ❌ ცუდი პრაქტიკა git checkout develop git add . git commit -m "quick fix" # ✅ სწორი გზა git checkout develop git flow feature start quick-fix git add . git commit -m "fix: resolve quick issue" git flow feature finish quick-fix ``` ### 2. Main Branch-ზე პირდაპირ Commit ```bash # ❌ არასდროს ასე git checkout main git add . git commit -m "urgent fix" # ✅ მუდმივად hotfix-ით git flow hotfix start urgent-fix git add . git commit -m "fix: resolve urgent issue" git flow hotfix finish urgent-fix ``` ### 3. Feature Branch-ების დაგროვება ```bash # ❌ ერთ Feature-ში მრავალი ფუნქცია git flow feature start big-feature # ... 50 commit-ი სხვადასხვა ფუნქციაზე # ✅ პატარა, ფოკუსირებული Feature-ები git flow feature start user-login git flow feature start user-registration git flow feature start password-reset ``` ### 4. Release Branch-ში მნიშვნელოვანი ფუნქციები ```bash # ❌ Release-ში ახალი ფუნქცია git checkout release/v1.2.0 git add new-feature.js git commit -m "feat: add new feature" # ✅ Release-ში მხოლოდ ბაგფიქსები git checkout release/v1.2.0 git add bug-fix.js git commit -m "fix: resolve minor bug" ``` ### 5. Tag-ების გამოტოვება ```bash # ❌ Tag-ების დაგვიანება git flow release finish v1.2.0 # tag-ი არ იქმნება # ✅ ყოველთვის Tag-ები git flow release finish v1.2.0 git push origin --tags ``` --- ## ალტერნატივები ### 1. GitHub Flow **მარტივი მოდელი:** ```bash main → feature → main ``` **მიესადაგება:** - პატარა გუნდები - Continuous Deployment - მარტივი პროდუქტები ### 2. GitLab Flow **Environment-based:** ```bash main → pre-production → production ``` **მიესადაგება:** - Environment-specific deployment - კომპლექსური infrastructure - Staging environments ### 3. OneFlow **Simplified Git Flow:** ```bash main → feature → main (tags) ``` **მიესადაგება:** - Git Flow-ის სირთულე ზედმეტია - რეგულარული releases - ავტომატიზებული testing --- ## ჩვენი გუნდისთვის რეკომენდაციები ### პროექტის სპეციფიკაცია **Hackem-ის პროექტებისთვის:** - Backend API services - Frontend React applications - Mobile applications - DevOps tools ### ადაპტირებული წესები ```bash # Branch სახელების კონვენცია feature/HACK-123-feature-name bugfix/HACK-456-bug-description hotfix/v1.2.3-critical-fix release/v1.2.0 # Commit message format type(scope): description # PR Labels - feature - bugfix - hotfix - documentation - refactor - needs-review - approved - ready-for-merge ``` ### Development Workflow ```bash # 1. Daily Standup-ის შემდეგ git checkout develop git pull origin develop git flow feature start HACK-123-new-feature # 2. Development # ... კოდის წერა ... # 3. Daily Push git push origin feature/HACK-123-new-feature # 4. Sprint-ის ბოლოს # PR შექმნა, review, merge # 5. Sprint Review-ის შემდეგ git flow release start v1.2.0 # 6. Release Day git flow release finish v1.2.0 ``` ### ავტომატიზაცია ```bash # Git hooks .git/hooks/pre-commit .git/hooks/commit-msg .git/hooks/pre-push # Scripts scripts/start-feature.sh scripts/finish-feature.sh scripts/create-release.sh scripts/hotfix-deploy.sh ``` ### მონიტორინგი ```bash # Release metrics - Feature delivery time - Bug fix time - Code review time - Deployment frequency - Lead time - MTTR (Mean Time To Recovery) ``` --- ## დასკვნა Git Flow არის ძლიერი ინსტრუმენტი დიდი გუნდებისთვის, რომლებსაც სჭირდებათ სტრუქტურირებული განვითარების პროცესი. სწორი იმპლემენტაციით, ის საგრძნობლად აუმჯობესებს: - **კოდის ხარისხს** - სტრუქტურირებული review პროცესი - **გუნდის პროდუქტიულობას** - ნათელი წესები და ავტომატიზაცია - **პროდუქტის სტაბილურობას** - კონტროლირებადი რელიზები - **რისკების მენეჯმენტს** - იზოლირებული ცვლილებები **გამოყენებამდე გაითვალისწინეთ:** - გუნდის ზომა (5+ დეველოპერი) - პროექტის კომპლექსურობა - რელიზების სიხშირე - ავტომატიზაციის დონე **წარმატების გასაღებები:** - გუნდის ტრენინგი - ავტომატიზაცია - კონსისტენტურობა - რეგულარული რევიუ და განახლება Git Flow-ის სწორი იმპლემენტაცია შეიძლება საფუძვლად დაედოს ჩვენი განვითარების პროცესების ოპტიმიზაციას და დროის მნიშვნელოვან დაზოგვას.