Fruitful™

FAA.ZONE™ Ecosystem 🦍

GitHub Developer Handbook and Staff Training Manual

Your A-Z Guide to Version Control and Collaboration

1. Introduction to GitHub

GitHub is a web-based platform that uses Git for version control. It's a powerful tool for developers to collaborate on projects, track changes, and manage their codebases efficiently. Think of it as a central hub where all your project's code lives, and where every change is meticulously recorded.

This manual will guide you through setting up Git and GitHub, understanding fundamental commands, and adopting best practices for a seamless development workflow within the FAA.ZONE Ecosystem.

2. GitHub & Git Setup: The Foundation

2.1 Creating a GitHub Account

If you don't already have one, your first step is to create a GitHub account. This account will host your repositories and allow you to interact with other developers' projects.

  1. Navigate to github.com/join.
  2. Follow the on-screen prompts to choose a username, enter your email address, and set a password.
  3. Verify your email address when prompted.

2.2 Installing Git

Git is the distributed version control system that GitHub is built upon. You need to install Git on your local machine to interact with GitHub repositories.

  • For macOS: Git is often pre-installed. You can check by opening Terminal and typing git --version. If not, install Xcode Command Line Tools:
    xcode-select --install
    Or use Homebrew:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    brew install git
  • For Windows: Download the Git for Windows installer from git-scm.com/download/win. Run the installer and follow the default options.
  • For Linux (Debian/Ubuntu):
    sudo apt update
    sudo apt install git

After installation, open your terminal (or Git Bash on Windows) and verify Git is installed correctly:

git --version

2.3 Configuring Git (Initial Setup)

You need to tell Git who you are so that your commits are correctly attributed.

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Replace "Your Name" and "[email protected]" with your actual name and the email associated with your GitHub account.

2.4 Setting up SSH Keys (Recommended)

SSH keys provide a more secure way to connect to GitHub without typing your username and password every time. It's highly recommended for a smoother workflow.

  1. Generate a new SSH key:

    Open your terminal and run the following command. Replace "[email protected]" with your GitHub email.

    ssh-keygen -t ed25519 -C "[email protected]"

    Press Enter for the default file location. You can set a passphrase for extra security, but it's optional.

  2. Start the SSH agent:
    eval "$(ssh-agent -s)"
  3. Add your SSH private key to the SSH agent:
    ssh-add ~/.ssh/id_ed25519

    (If you created a different filename, use that instead of id_ed25519)

  4. Copy your SSH public key to the clipboard:
    • macOS:
      pbcopy < ~/.ssh/id_ed25519.pub
    • Windows (Git Bash):
      cat ~/.ssh/id_ed25519.pub | clip
    • Linux: You might need to install xclip or xsel first:
      sudo apt-get install xclip
      xclip -sel clip < ~/.ssh/id_ed25519.pub
  5. Add the SSH key to your GitHub account:
    • Go to GitHub Settings (github.com/settings/keys).
    • Click "New SSH key" or "Add SSH key".
    • Give it a descriptive title (e.g., "My Work Laptop").
    • Paste the copied public key into the "Key" field.
    • Click "Add SSH key".

3. Essential Git Commands: Your Daily Toolkit

These are the commands you'll use most frequently. Understanding their purpose is key to effective version control.

3.1 git init: Initialize a New Repository

This command creates a new Git repository in the current directory. It's typically done once per project if you're starting from scratch locally.

cd my-new-project/
git init

This creates a hidden .git directory where Git stores all its tracking information.

3.2 git clone: Copy an Existing Repository

Use this to get a copy of an existing repository (e.g., from GitHub) onto your local machine. This sets up the remote connection automatically.

git clone <repository-url>

Example: git clone [email protected]:your-org/your-repo.git (using SSH) or git clone https://github.com/your-org/your-repo.git (using HTTPS).

3.3 git status: Check Your Working Directory Status

This command shows you which files have been modified, staged, or are untracked. It's your quick health check for your local repository.

git status

You'll see files in red (modified/untracked) and green (staged for commit).

3.4 git add: Stage Changes for Commit

Before you commit changes, you need to "stage" them. This tells Git which specific changes you want to include in your next commit.

git add <file-name>        # Stage a specific file
git add .                  # Stage all changes in the current directory
git add -u                 # Stage changes to tracked files only

Always run git status after git add to confirm files are staged.

3.5 git commit: Record Changes to the Repository

A commit is a snapshot of your repository at a specific point in time. Each commit has a unique ID and a commit message explaining the changes.

git commit -m "Your descriptive commit message"

A good commit message concisely describes *what* changed and *why*. Avoid vague messages like "Fixed bugs".

For multi-line messages, omit -m and Git will open your default text editor.

3.6 git log: View Commit History

Shows a chronological list of commits in the current branch. Useful for understanding project history.

git log                    # Full log
git log --oneline          # Concise one-line view
git log --graph --oneline --all # Visualizes branches and merges

3.7 git branch: Manage Branches

Branches allow you to work on new features or bug fixes in isolation without affecting the main codebase.

git branch                 # List all local branches
git branch <new-branch-name> # Create a new branch
git branch -d <branch-to-delete> # Delete a local branch (after merging)

3.8 git checkout: Switch Branches or Restore Files

Moves your working directory to a different branch, or retrieves a specific file from a commit.

git checkout <branch-name> # Switch to an existing branch
git checkout -b <new-branch-name> # Create and switch to a new branch
git checkout <commit-hash> -- <file-path> # Restore a file from a specific commit

3.9 git pull: Fetch and Integrate Remote Changes

Updates your local branch with the latest changes from the remote repository. It's a combination of git fetch (downloads changes) and git merge (integrates them).

git pull origin <branch-name>

Often simplified to git pull if your branch is set to track a remote branch.

Always git pull before starting work and before pushing to ensure you're on the latest version and to minimize merge conflicts.

3.10 git push: Upload Local Commits to Remote

Sends your committed changes from your local branch to the remote repository on GitHub.

git push origin <branch-name>

The first time you push a new branch, you might need to set the upstream: git push -u origin <branch-name>.

Ensure your changes are committed and your local branch is up-to-date with the remote (via git pull) before pushing.

3.11 git merge: Integrate Changes from One Branch into Another

Combines the history of two (or more) development lines together. Commonly used to bring changes from a feature branch into main or develop.

# First, switch to the branch you want to merge *into*
git checkout main
# Then, merge the feature branch into the current branch
git merge feature-branch-name

Git will attempt to merge automatically. If there are conflicts, you'll need to resolve them manually.

4. GitHub Workflow: Collaboration in Practice

Beyond basic Git commands, GitHub introduces powerful features for team collaboration.

4.1 Repository Creation

  1. Go to GitHub.com.
  2. Click the "+" sign in the top right corner and select "New repository".
  3. Give your repository a meaningful name (e.g., faa-zone-api-service).
  4. Add a brief description.
  5. Choose "Public" or "Private" (usually Private for internal projects).
  6. Initialize with a README file (recommended).
  7. Add a .gitignore file (select a template like "Node" or "Python" based on your project).
  8. Choose a license (e.g., MIT License for open source, or leave blank for proprietary).
  9. Click "Create repository".

4.2 Branching Strategy (Simplified)

We will primarily use a "GitHub Flow" inspired strategy for feature development:

  • main branch: This branch should always be deployable. Only merged via Pull Requests after review.
  • Feature/Bugfix branches: For every new feature, bug fix, or significant change, create a new branch from main.
    git checkout main
    git pull origin main
    git checkout -b feature/your-awesome-feature

4.3 Pull Requests (PRs): The Core of Collaboration

Pull Requests are how you propose changes, discuss them, and get them reviewed before merging into a main branch.

  1. Create a new branch and make your changes (as described in 4.2).
  2. Commit your changes:
    git add .
    git commit -m "feat: implement user authentication"
  3. Push your branch to GitHub:
    git push -u origin feature/your-awesome-feature
  4. Create the Pull Request on GitHub:

    After pushing, GitHub will usually provide a direct link in the terminal to create a PR. Alternatively, go to your repository on GitHub, navigate to the "Pull requests" tab, and click "New pull request".

    Select your feature branch as the "compare" branch and main as the "base" branch.

  5. Write a descriptive PR title and description:

    Explain what the PR does, why it's needed, and any relevant context (e.g., linking to an issue).

  6. Request reviews: Assign reviewers from your team.
  7. Address feedback and push new commits: When reviewers provide comments, make the necessary changes on your local branch, commit them, and push. These new commits will automatically appear in the existing PR.
  8. Merge the PR: Once approved and all checks pass, a team lead or designated reviewer will merge the PR into the main branch.
  9. Delete the branch (optional but recommended): After merging, delete the feature branch both on GitHub and locally:
    git branch -d feature/your-awesome-feature

4.4 Handling Merge Conflicts

Merge conflicts occur when Git cannot automatically reconcile changes between two branches (e.g., two people modified the same line of code).

  1. Identify the conflict: Git will notify you in the terminal during git pull or git merge.
    Auto-merging conflicting-file.js
    CONFLICT (content): Merge conflict in conflicting-file.js
    Automatic merge failed; fix conflicts and then commit the result.
  2. Open the conflicted file(s): Your IDE will highlight the conflicting sections with markers like <<<<<<<, =======, and >>>>>>>.
    <<<<<<< HEAD
        console.log('My new feature');
    =======
        console.log('Existing functionality');
    >>>>>>> feature/another-branch

    HEAD represents your current branch's version, and the section after ======= is the incoming change.

  3. Manually resolve: Edit the file to combine the changes correctly. Remove the conflict markers.
  4. Stage the resolved file:
    git add conflicting-file.js
  5. Commit the merge:
    git commit -m "Merge branch 'feature/another-branch' into main (resolved conflicts)"

    Git will often pre-populate a merge commit message; you can usually save and close it.

4.5 Issues and Project Boards

GitHub's "Issues" tab is for tracking tasks, bugs, and feature requests. "Projects" (or "Project boards") help organize these issues into Kanban-style boards for workflow management.

  • Creating an Issue: Go to the "Issues" tab, click "New issue", provide a title and description, and optionally assign labels, assignees, or milestones.
  • Using Project Boards: Create new project boards (e.g., "To Do", "In Progress", "Done") and drag issues between columns to update their status.

4.6 GitHub Pages (Basic Setup)

GitHub Pages allows you to host static websites directly from your GitHub repositories.

  1. In your repository, go to "Settings" -> "Pages".
  2. Under "Branch", select the branch you want to deploy from (usually main or gh-pages) and the folder (e.g., /root or /docs).
  3. Save, and GitHub will deploy your site to yourusername.github.io/your-repo-name.

4.7 GitHub Actions (Brief Overview)

GitHub Actions is a CI/CD (Continuous Integration/Continuous Deployment) platform built into GitHub. It allows you to automate workflows directly in your repository (e.g., running tests, building code, deploying applications) on every push or pull request.

Actions are defined in YAML files (.github/workflows/*.yml) and trigger based on events.

Example workflow for running tests:

# .github/workflows/ci.yml
name: CI

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main, develop ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Use Node.js
      uses: actions/setup-node@v3
      with:
        node-version: '18'
    - name: Install dependencies
      run: npm ci
    - name: Run tests
      run: npm test

5. Fruitful™: A Key Component of the FAA.ZONE Ecosystem

Fruitful™ represents a critical initiative within the FAA.ZONE Ecosystem. It is designed to foster innovation and generate valuable outcomes through a collaborative, structured approach. This section outlines its purpose and how it integrates with our GitHub workflows.

5.1 Purpose and Vision of Fruitful™

Fruitful™ aims to be the engine for our creative and problem-solving processes. It embodies our commitment to:

  • Driving Innovation: Encouraging the exploration of new ideas and technologies.
  • Maximizing Output: Ensuring that development efforts lead to tangible and impactful results.
  • Fostering Collaboration: Providing frameworks and tools that enhance teamwork and knowledge sharing.
  • Streamlining Development Cycles: Implementing efficient practices from concept to deployment.

The "Fruitful™" logo represents growth, abundance, and the successful cultivation of ideas within our ecosystem, signifying the fertile ground we provide for projects to flourish from conception to completion.

5.2 Integration with GitHub Workflows

Fruitful™ is not just a concept; it's integrated into our daily development practices, primarily through our GitHub workflow. All projects under the Fruitful™ umbrella will adhere to the following:

  • Dedicated Repositories: Each Fruitful™ project will have its own dedicated GitHub repository within the FAA.ZONE organization, following clear naming conventions (e.g., fruitful-project-name).
  • Issue Tracking: All tasks, features, and bugs related to Fruitful™ projects will be meticulously tracked using GitHub Issues. Specific labels (e.g., fruitful-feature, fruitful-bug, fruitful-enhancement) will be consistently applied for easy identification, filtering, and reporting.
  • Project Boards: Kanban-style project boards will be utilized extensively to visualize the progress of Fruitful™ initiatives. This allows for transparent tracking of tasks through stages like "To Do", "In Progress", "Code Review", and "Done", providing a clear overview of project status.
  • Strict Pull Request Process: Every change, no matter how small, will go through a rigorous Pull Request process. This includes mandatory code reviews by at least one other team member, ensuring adherence to coding standards, architectural patterns, and overall code quality. Automated checks via GitHub Actions will also be in place for linting, testing, and security scanning.
  • Automated CI/CD for Fruitful™: Continuous Integration and Continuous Deployment pipelines, defined using GitHub Actions, will be central to Fruitful™ projects. These pipelines will automatically build, test, and potentially deploy code changes upon every push to a feature branch and merge into `main`, ensuring rapid feedback and consistent deployments.
  • Comprehensive Documentation: Each Fruitful™ project repository will contain a clear and up-to-date `README.md` file, alongside additional documentation (e.g., `CONTRIBUTING.md`, `ARCHITECTURE.md`, `docs/` folder) detailing setup, usage, architecture, and deployment procedures. This is crucial for onboarding new team members and maintaining project longevity.
  • Regular Sync and Communication: Team members working on Fruitful™ projects are expected to regularly pull the latest changes from the `main` branch, actively participate in code reviews, and communicate progress and blockers through GitHub's issue and PR comments. Synchronized discussions and feedback loops are vital for the iterative nature of Fruitful™ initiatives.

By rigorously applying these GitHub-centric practices, Fruitful™ ensures that our innovations are not only well-conceived but also robustly developed and seamlessly integrated into the FAA.ZONE Ecosystem.

6. Best Practices for Effective Git & GitHub Usage

Adhering to these practices will make your team more efficient and your codebase more maintainable.

  • Atomic Commits: Each commit should represent a single, logical change. Avoid committing multiple unrelated changes in one go.
  • Descriptive Commit Messages: Start with a concise subject line (imperative mood, max 50-72 chars) and a blank line, followed by a more detailed body if needed.
    feat: Add user profile page
    
    This commit introduces a new user profile page with editable fields
    for name, email, and password. It also includes validation for
    form inputs and integration with the backend API for data retrieval.
    Resolves #123.
  • Pull Regularly: Always git pull from your base branch (e.g., main) before starting work and before creating a Pull Request to minimize merge conflicts.
  • Code Reviews are Mandatory: Every PR must be reviewed and approved by at least one other team member before merging. Provide constructive feedback.
  • Keep Branches Short-Lived: Create branches for specific features or bug fixes, and merge them into the main branch as soon as they are complete and reviewed.
  • Use .gitignore: Prevent unwanted files (e.g., node_modules, .env, build artifacts) from being committed by adding them to your .gitignore file.
  • Protect Main Branches: Configure branch protection rules on GitHub for main (and any other critical branches) to require PRs, passing status checks, and approvals.
  • Regularly Sync Forks: If you're working with a forked repository, regularly sync your fork with the upstream repository to keep it up-to-date.
    # Add upstream remote if not already added
    git remote add upstream https://github.com/original-org/original-repo.git
    
    # Fetch from upstream
    git fetch upstream
    
    # Checkout your local main branch
    git checkout main
    
    # Merge upstream changes into your local main
    git merge upstream/main
    
    # Push changes to your fork (if applicable)
    git push origin main

7. Troubleshooting Common Git & GitHub Issues

Here are some common problems you might encounter and how to resolve them.

7.1 Merge Conflicts (Revisited)

If you encounter CONFLICT (content): Merge conflict..., refer back to section 4.4. The key is to manually edit the file to resolve the conflicting lines, then git add and git commit.

7.2 "Failed to push some refs to..." / "Updates were rejected"

This means your local branch is behind the remote branch. Someone else has pushed changes that you don't have locally.

git pull origin <your-branch-name>
# Resolve any conflicts if they arise
git push origin <your-branch-name>
  • HTTPS Token Issues: If you're using HTTPS and constantly prompted for a password, your credential manager might not be set up correctly, or your Personal Access Token (PAT) might have expired or be invalid.

    GitHub recommends using PATs instead of passwords for HTTPS. Generate a new PAT from GitHub Settings -> Developer settings -> Personal access tokens. Give it appropriate scopes (e.g., repo). When prompted for a password, use the PAT.

  • 7.4 Accidental Commits / Need to Undo Changes

    Use with extreme caution, especially on shared branches.

    • Undo local (unpushed) commit:
      git reset HEAD~1       # Unstages the last commit, keeps changes
      git reset --hard HEAD~1 # Discards the last commit and its changes (DANGEROUS!)
    • Undo pushed commit (requires force push - use with caution):
      git revert <commit-hash> # Creates a new commit that undoes the specified commit (safer)
      git reset --hard <commit-hash-before-undesired-commit>
      git push --force origin <branch-name> # DANGEROUS! Overwrites remote history. ONLY use if you are 100% sure and others haven't pulled your changes.

    8. Advanced Git Commands: Expanding Your Toolkit

    This section provides a comprehensive list of Git commands beyond the daily essentials, offering more powerful ways to manage your codebase and history. Each command includes a brief description of its primary function.

    Branching & Merging

    • git switch <branch-name>: A newer, safer alternative to `git checkout` for switching branches.
    • git switch -c <new-branch-name>: Creates and switches to a new branch.
    • git branch -m <old-name> <new-name>: Renames a local branch.
    • git merge --abort: Stops a merge process if conflicts are too complex or you change your mind.
    • git rebase <base-branch>: Rewrites commit history by moving a series of commits to a new base. Use with caution on shared branches.
    • git rebase --continue: Continues a rebase after resolving conflicts.
    • git rebase --abort: Aborts an ongoing rebase operation.
    • git cherry-pick <commit-hash>: Applies changes from a specific commit from one branch onto another.
    • git stash: Temporarily saves changes that are not ready to be committed, cleaning up the working directory.
    • git stash pop: Applies the most recently stashed changes and removes them from the stash list.
    • git tag <tag-name>: Creates a lightweight tag (e.g., for release versions).
    • git tag -a <tag-name> -m "Message": Creates an annotated tag (recommended for releases, includes metadata).

    Inspecting & Debugging

    • git diff: Shows changes between the working tree and the index, or between two commits/branches.
    • git diff --staged: Shows changes between the index and the last commit.
    • git blame <file-name>: Shows what revision and author last modified each line of a file.
    • git reflog: Displays a log of all actions performed in your local repository, including checkouts and resets. Useful for recovering lost commits.
    • git shortlog: Summarizes `git log` output, grouped by author.
    • git show <commit-hash>: Displays metadata and content changes of a single commit, tag, or tree object.

    Remote & Configuration

    • git remote -v: Lists all configured remote repositories and their URLs.
    • git remote add <name> <url>: Adds a new remote repository.
    • git remote rm <name>: Removes a remote.
    • git fetch: Downloads objects and refs from another repository (e.g., origin), but does not merge them.
    • git config --list: Lists all Git configurations.
    • git config --global core.editor "code --wait": Sets VS Code as the default Git editor (example).

    This list is a starting point; Git has many more commands and options. Use git help <command> for detailed documentation on any specific command (e.g., git help rebase).

    9. Using Git Desktop Applications

    While the command line provides full control over Git, desktop applications offer a visual interface that can simplify many common operations, especially for those who prefer graphical tools. Popular Git desktop apps include GitHub Desktop, GitKraken, Sourcetree, and VS Code's integrated Git features.

    The core concepts and workflows (cloning, committing, pushing, pulling, branching, creating Pull Requests) remain the same, but the method of execution changes from typing commands to clicking buttons and interacting with visual elements.

    9.1 Common Operations in a Git Desktop App

    • Cloning a Repository:

      Typically found under "File" or "Repository" menu as "Clone Repository". You'll provide the repository URL (HTTPS or SSH) and choose a local directory.

      Equivalent to: git clone <repository-url>

    • Staging Changes:

      Desktop apps usually show a list of modified files. You can select individual files or all changed files to stage them for the next commit. This might involve checking a box next to the file name or dragging it to a "Staged Changes" area.

      Equivalent to: git add <file-name> or git add .

    • Committing Changes:

      After staging, there's usually a dedicated area to write your commit message (subject and optional description) and a "Commit" button. The app will automatically include your configured Git user name/email.

      Equivalent to: git commit -m "Your message"

    • Pulling Latest Changes:

      A "Pull" or "Fetch origin" button (often with a down arrow icon) will retrieve and integrate changes from the remote repository to your current local branch. It's crucial to do this frequently.

      Equivalent to: git pull

    • Pushing Local Changes:

      A "Push" or "Push origin" button (often with an up arrow icon) sends your committed local changes to the remote repository.

      Equivalent to: git push

    • Creating and Switching Branches:

      Most apps have a branch selector dropdown where you can see existing branches and an option to "New Branch" or "Create Branch". Switching is as simple as selecting a different branch from the list.

      Equivalent to: git branch <new-branch> and git checkout <branch-name> (or git switch)

    • Creating a Pull Request:

      After pushing a new branch to GitHub, many desktop apps will provide a direct link or a button like "Create Pull Request" that takes you directly to GitHub's PR creation page, pre-filling much of the information.

      Equivalent to: Pushing a new branch and then navigating to GitHub.com to create the PR.

    • Resolving Merge Conflicts:

      When a pull or merge results in conflicts, desktop apps often highlight the conflicting files and provide a visual interface to help you manually resolve them, showing "incoming" and "current" changes side-by-side or inline. After editing, you'll mark the conflict as resolved within the app.

      Equivalent to: Manual file editing, then git add and git commit for the merge.

    While the visual tools simplify the *execution*, understanding the underlying Git concepts from the command-line sections (e.g., staging area, commit history, branching) will make you a more effective user of any Git desktop application. They are two different interfaces to the same powerful system.

    10. Conclusion

    This handbook provides a comprehensive foundation for using Git and GitHub effectively within the FAA.ZONE Ecosystem. Mastering these tools is crucial for our collaborative success and the efficient management of our codebase.

    Remember to practice regularly, utilize GitHub's documentation for deeper dives, and always communicate changes through Pull Requests. Your consistent adherence to these guidelines ensures a smooth and productive development experience for everyone.

    Should you encounter issues not covered here, consult official Git and GitHub documentation, or refer to common online resources. This manual is designed to empower you to resolve issues independently and contribute confidently.