Skip to content

🐙 GitHub & Version Control

GitHub is a web-based hosting service for Git repositories, providing a unified workspace map for revision tracking, peer-to-peer collaboration, code hosting, and automated CI/CD pipelines.


📊 Tool Datasheet

MetricDetails
Tool NameGit & GitHub
CategoryDistributed Version Control & Collaboration Platform
PurposeCode history management, staging environments, code review pipelines, and automated application releases.
LicenseOpen Source (Git), Commercial/Free Tier hosted platform (GitHub)
Core ClientsGit CLI, GitHub Desktop, VS Code Git extension

🛠️ Capabilities

  1. Branching & Merging: Safe isolation of development tasks via feature branches, allowing concurrent modifications without corrupting the main codebase.
  2. Pull Requests & Reviews: Peer-to-peer code reviews, inline comments, and automated security checks before merging code into main branches.
  3. GitHub Actions: Build, test, and deploy applications automatically on specific triggers (push, pull request, cron schedules).
  4. Issue Tracking & Project Management: Organize feature requests, bug logs, and milestones directly alongside source repository code.
  5. Secure Secret Management: Store database passwords, API keys, and server credentials securely using GitHub Secrets for CI/CD builds.

🧭 Step-by-Step Tutorial & Setup

This tutorial guides you through setting up a local repository, branching, committing changes, and configuring a basic automated test suite on GitHub.

1. Global Git Configuration

Configure your development credentials on your local system:

bash
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git config --global init.defaultBranch main

2. Initialize a Local Repository

Initialize version tracking inside your local project workspace:

bash
cd ~/AI_BOOTCAMP/labs/my-project
git init

Create a .gitignore file to prevent committing cache and credentials files:

text
# .gitignore
.env
__pycache__/
*.pyc
.conda/
miniconda3/
node_modules/
dist/

3. Stage & Commit Code

Stage all project workspace files and commit them to establish a codebase baseline:

bash
git add .
git commit -m "feat: initial commit with project scaffold and environment configuration"

4. Configure GitHub Action Pipeline (CI/CD)

Configure a basic automated workflow that runs your pytest suites every time you push code to GitHub.

Create a file at .github/workflows/python-tests.yml:

yaml
name: Python Application CI

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

jobs:
  build-and-test:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout Code
      uses: actions/checkout@v4

    - name: Setup Python
      uses: actions/setup-python@v5
      with:
        python-version: '3.11'

    - name: Install uv & Dependencies
      run: |
        curl -LsSf https://astral.sh/uv/install.sh | sh
        uv pip install --system pytest httpx pydantic

    - name: Run Tests
      run: |
        pytest tests/

💡 Sample Ideation to Test

To test version control workflows, try setting up these pipeline scenarios:

  1. Enforce Pre-Commit hooks: Install pre-commit locally to run formatting tools (like black or ruff) automatically before allowing a git commit.
  2. Pull Request Gates: Set up branch protection rules on your GitHub repository to require at least one code approval and a passing GitHub Actions status before allowing code to merge into main.