From 408f9d60447f25865f45d8a6b1873d30501c4cd8 Mon Sep 17 00:00:00 2001 From: "Akhib.Shaik" Date: Mon, 3 Nov 2025 14:25:00 +0530 Subject: [PATCH] added branch setup --- GIT_BRANCH_SETUP.md | 299 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 GIT_BRANCH_SETUP.md diff --git a/GIT_BRANCH_SETUP.md b/GIT_BRANCH_SETUP.md new file mode 100644 index 0000000..4480e3f --- /dev/null +++ b/GIT_BRANCH_SETUP.md @@ -0,0 +1,299 @@ +# Git Branch Setup Guide + +## Creating Branches: akhib and dundu + +### Quick Commands + +```bash +# Create and push akhib branch +git checkout -b akhib +git push -u origin akhib + +# Create and push dundu branch +git checkout -b dundu +git push -u origin dundu + +# Go back to main branch +git checkout main +``` + +## Detailed Step-by-Step + +### Step 1: Check Your Current Branch + +```bash +git branch +``` + +This shows which branch you're currently on (marked with *). + +### Step 2: Create akhib Branch + +```bash +# Create new branch from current position +git checkout -b akhib + +# Verify you're on the new branch +git branch + +# Push to remote and set upstream +git push -u origin akhib +``` + +### Step 3: Create dundu Branch + +```bash +# Go back to main first +git checkout main + +# Create new branch from main +git checkout -b dundu + +# Push to remote and set upstream +git push -u origin dundu +``` + +### Step 4: Verify All Branches Exist + +```bash +# List local branches +git branch + +# List all branches (local + remote) +git branch -a +``` + +You should see: +``` +* main + akhib + dundu + remotes/origin/akhib + remotes/origin/dundu + remotes/origin/main +``` + +## Branch Workflow for Team + +### For Developer Working on akhib Branch + +```bash +# Switch to akhib branch +git checkout akhib + +# Make sure it's up to date +git pull origin akhib + +# Make changes, then commit +git add . +git commit -m "Your commit message" + +# Push changes +git push origin akhib +``` + +### For Developer Working on dundu Branch + +```bash +# Switch to dundu branch +git checkout dundu + +# Make sure it's up to date +git pull origin dundu + +# Make changes, then commit +git add . +git commit -m "Your commit message" + +# Push changes +git push origin dundu +``` + +## Merging Changes + +### Merge akhib into main + +```bash +# Switch to main +git checkout main + +# Pull latest changes +git pull origin main + +# Merge akhib branch +git merge akhib + +# Push merged changes +git push origin main +``` + +### Merge dundu into main + +```bash +# Switch to main +git checkout main + +# Pull latest changes +git pull origin main + +# Merge dundu branch +git merge dundu + +# Push merged changes +git push origin main +``` + +## Branch Protection (Recommended) + +After creating branches, consider setting up branch protection rules on GitHub/GitLab: + +1. **Protect main branch** - Require pull requests +2. **Require reviews** - At least 1 approval before merging +3. **Require tests** - Ensure CI/CD passes + +## Common Branch Commands + +```bash +# List all branches +git branch -a + +# Switch branches +git checkout branch-name + +# Create new branch +git checkout -b new-branch-name + +# Delete local branch +git branch -d branch-name + +# Delete remote branch +git push origin --delete branch-name + +# Rename current branch +git branch -m new-name + +# See which branch you're on +git branch + +# Update all branches from remote +git fetch --all + +# See commits difference between branches +git log main..akhib +``` + +## Branch Strategy Recommendation + +### Main Branch +- **Purpose:** Production-ready code +- **Protection:** Require pull requests +- **Who commits:** No direct commits (only via PR) + +### akhib Branch +- **Purpose:** Akhib's development work +- **Protection:** Optional +- **Who commits:** Akhib (and approved team members) + +### dundu Branch +- **Purpose:** Dundu's development work +- **Protection:** Optional +- **Who commits:** Dundu (and approved team members) + +## Workflow Example + +```mermaid +graph LR + A[main] --> B[akhib branch] + A --> C[dundu branch] + B --> D[Pull Request to main] + C --> E[Pull Request to main] + D --> A + E --> A +``` + +**Recommended Flow:** +1. Developer creates feature on their branch (akhib/dundu) +2. Commits and pushes regularly +3. When ready, creates Pull Request to main +4. Team reviews the PR +5. After approval, merge to main +6. Delete feature branch (optional) or keep for next feature + +## Syncing Branches + +### Keep akhib up to date with main + +```bash +git checkout akhib +git pull origin main +git push origin akhib +``` + +### Keep dundu up to date with main + +```bash +git checkout dundu +git pull origin main +git push origin dundu +``` + +## Troubleshooting + +### Error: "branch already exists" + +```bash +# If branch exists locally, just switch to it +git checkout akhib + +# If you want to recreate it +git branch -d akhib +git checkout -b akhib +``` + +### Error: "failed to push some refs" + +```bash +# Pull first, then push +git pull origin akhib +git push origin akhib +``` + +### Merge Conflicts + +```bash +# When merge conflict occurs +git status # See conflicted files + +# Edit conflicted files manually +# Look for <<<<<<, ======, >>>>>> markers + +# After fixing conflicts +git add . +git commit -m "Resolve merge conflicts" +git push +``` + +## Quick Reference + +| Command | Description | +|---------|-------------| +| `git checkout -b akhib` | Create akhib branch | +| `git push -u origin akhib` | Push and track akhib | +| `git checkout akhib` | Switch to akhib | +| `git branch` | List local branches | +| `git branch -a` | List all branches | +| `git merge akhib` | Merge akhib into current | +| `git pull origin akhib` | Update akhib from remote | + +## Setting Up Branch Protection (GitHub) + +1. Go to: Settings → Branches → Add rule +2. Branch name pattern: `main` +3. Enable: + - ✅ Require pull request reviews before merging + - ✅ Require status checks to pass + - ✅ Require branches to be up to date +4. Save changes + +Now your branches are ready for team collaboration! 🎉 +