# GIT WORKFLOW - EXAM SCHEDULING SYSTEM **Project:** Exam Planner Desktop Application **Team:** Team 3, Section 1 **Version Control:** Git + GitHub --- ## BRANCHING STRATEGY ### Branch Structure ``` main (production-ready code) └── develop (integration branch) ├── feature/database-schema (Kerem's work) ├── feature/csv-import (Kerem's work) ├── feature/csp-solver (Milena's work) ├── feature/constraint-validation (Milena's work) ├── feature/ui-main-window (Rabia's work) ├── feature/import-view (Rabia's work) ├── feature/import-controller (Sefa's work) ├── feature/generation-controller (Sefa's work) ├── feature/dao-tests (Feyza's work) ├── feature/algorithm-tests (Feyza's work) └── bugfix/constraint-validation-issue (Any team member) ``` ### Branch Types #### 1. `main` Branch - **Purpose:** Production-ready, stable code only - **Protection:** Requires PR approval from Emin (Documentation Lead) - **Merging:** Only from `develop` branch - **Tagging:** Every merge to main gets a version tag (v1.0.0, v1.1.0, etc.) - **Never:** Commit directly to `main` #### 2. `develop` Branch - **Purpose:** Integration branch for all features - **Protection:** Requires at least 1 PR approval - **Testing:** All tests must pass before merge - **Never:** Commit directly to `develop` (always use feature branches) #### 3. `feature/*` Branches - **Purpose:** New features or enhancements - **Naming:** `feature/short-description` (e.g., `feature/csv-import`) - **Base:** Created from `develop` - **Merge to:** `develop` via Pull Request - **Lifetime:** Delete after successful merge - **Examples:** - `feature/database-schema` - `feature/csp-solver` - `feature/classroom-view` - `feature/export-excel` #### 4. `bugfix/*` Branches - **Purpose:** Fix bugs found during development - **Naming:** `bugfix/issue-description` (e.g., `bugfix/constraint-validation`) - **Base:** Created from `develop` - **Merge to:** `develop` via Pull Request - **Examples:** - `bugfix/duplicate-student-detection` - `bugfix/constraint-validation-boundary` - `bugfix/ui-table-alignment` #### 5. `hotfix/*` Branches (Emergency Only) - **Purpose:** Critical fixes for production code - **Naming:** `hotfix/critical-issue` - **Base:** Created from `main` - **Merge to:** Both `main` AND `develop` - **Use:** Only for critical bugs in production - **Examples:** - `hotfix/database-corruption` - `hotfix/solver-infinite-loop` #### 6. `refactor/*` Branches - **Purpose:** Code refactoring (no functional changes) - **Naming:** `refactor/component-name` - **Base:** Created from `develop` - **Merge to:** `develop` via Pull Request - **Examples:** - `refactor/dao-layer-optimization` - `refactor/algorithm-performance` #### 7. `test/*` Branches - **Purpose:** Adding or improving tests - **Naming:** `test/component-name` - **Base:** Created from `develop` - **Merge to:** `develop` via Pull Request - **Examples:** - `test/dao-integration-tests` - `test/constraint-validator-edge-cases` #### 8. `docs/*` Branches - **Purpose:** Documentation updates - **Naming:** `docs/document-name` - **Base:** Created from `develop` - **Merge to:** `develop` via Pull Request - **Examples:** - `docs/algorithm-design` - `docs/user-manual` --- ## GIT WORKFLOW COMMANDS ### 1. Starting a New Feature ```bash # Make sure you have latest develop git checkout develop git pull origin develop # Create new feature branch git checkout -b feature/csv-import # Work on your feature (make changes, add files) # ... # Stage and commit your changes git add src/main/java/com/se302/examscheduler/service/ImportService.java git commit -m "feat(import): Add CSV parser for student data" # Push to remote git push origin feature/csv-import # If branch doesn't exist on remote yet git push -u origin feature/csv-import ``` ### 2. Making Commits ```bash # Check what files have changed git status # View changes before committing git diff # Stage specific files git add file1.java file2.java # Or stage all changes git add . # Commit with descriptive message git commit -m "feat(dao): Implement StudentDAO with batch insert" # Push to remote branch git push origin feature/csv-import ``` ### 3. Keeping Your Branch Up-to-Date ```bash # While working on feature branch, periodically sync with develop # Fetch latest changes from remote git fetch origin # Rebase your branch on latest develop (preferred for clean history) git rebase origin/develop # Or merge develop into your branch (creates merge commit) git merge origin/develop # If conflicts occur during rebase # 1. Resolve conflicts in files # 2. Stage resolved files git add resolved-file.java # 3. Continue rebase git rebase --continue # Force push after rebase (only if you haven't pushed yet or working alone on branch) git push origin feature/csv-import --force-with-lease ``` ### 4. Creating a Pull Request **After pushing your feature branch:** 1. Go to GitHub repository 2. Click "Pull requests" tab 3. Click "New pull request" 4. Set base branch: `develop` 5. Set compare branch: `feature/csv-import` 6. Fill in PR template: - Title: Brief description (e.g., "Add CSV import functionality") - Description: Detailed changes, testing done, screenshots if UI - Link related issues: "Closes #15" 7. Request reviewers (at least one team member) 8. Assign yourself 9. Add labels (feature, bug, documentation, etc.) 10. Create pull request ### 5. Reviewing a Pull Request **As a reviewer:** ```bash # Fetch the PR branch git fetch origin git checkout feature/csv-import # Test the changes locally mvn clean test mvn javafx:run # Review code in IDE # Leave comments on GitHub PR page # If changes requested # - Author makes changes # - Author pushes to same branch (PR updates automatically) # If approved # - Click "Approve" on GitHub # - Merge when all checks pass ``` ### 6. Merging a Pull Request **After PR is approved:** **Option A: Squash and Merge (Recommended)** - Combines all commits into one clean commit - Use for most feature branches - Keeps develop history clean - Click "Squash and merge" on GitHub **Option B: Rebase and Merge** - Replays all commits on top of develop - Use for well-organized commit history - Click "Rebase and merge" on GitHub **Option C: Merge Commit** - Creates a merge commit preserving all commits - Use for large features with meaningful commit history - Click "Merge pull request" on GitHub **After merging:** ```bash # Delete the remote feature branch (GitHub does this automatically) # Delete your local feature branch git checkout develop git pull origin develop git branch -d feature/csv-import # If git complains, force delete git branch -D feature/csv-import ``` ### 7. Releasing to Main **When develop is ready for release:** ```bash # Ensure develop is stable git checkout develop git pull origin develop mvn clean test # All tests must pass # Create PR from develop to main # On GitHub: # 1. New Pull Request: develop -> main # 2. Title: "Release v1.0.0" # 3. Description: List of features included # 4. Request review from Emin (Documentation Lead) # After approval and merge git checkout main git pull origin main # Tag the release git tag -a v1.0.0 -m "Release version 1.0.0 - Initial delivery" git push origin v1.0.0 ``` --- ## COMMIT MESSAGE GUIDELINES ### Format ``` ():