Skip to content

Latest commit

 

History

History
160 lines (119 loc) · 3.94 KB

File metadata and controls

160 lines (119 loc) · 3.94 KB

Git & GitHub

Welcome to the Git and GitHub section! This guide will help you understand version control systems that are essential for any developer.

What are Git and GitHub?

Git is a distributed version control system that helps you track changes in your code and collaborate with others. It lets you save snapshots of your project and return to them when needed.

GitHub is a web-based platform built around Git that adds collaboration features, issue tracking, project management, and more. It's where many open-source projects live and where developers showcase their work.

Learning Path

Git Basics

  1. Setting Up

    • Installing Git
    • Configuring your identity
    • Basic terminal/command line navigation
  2. Core Concepts

    • Repositories
    • Commits
    • Branches
    • The staging area (index)
    • Working directory
  3. Essential Commands

    • git init - Create a new repository
    • git clone - Copy a repository
    • git add - Stage changes
    • git commit - Record changes
    • git status - Check status
    • git log - View history
    • git diff - See changes
    • git checkout - Switch branches
  4. Branching and Merging

    • Creating branches
    • Switching between branches
    • Merging branches
    • Resolving merge conflicts

GitHub Skills

  1. Account Setup

    • Creating an account
    • Setting up SSH keys
    • Configuring profile
  2. Remote Repositories

    • git remote - Managing remotes
    • git push - Uploading changes
    • git pull - Downloading changes
    • git fetch - Getting updates
  3. Collaboration

    • Forking repositories
    • Creating pull requests
    • Code reviews
    • Issues and discussions
  4. GitHub Features

    • GitHub Pages
    • GitHub Actions (CI/CD)
    • Project boards
    • GitHub Discussions

Advanced Git

  1. History Manipulation

    • Interactive rebase
    • Cherry-picking
    • Reset vs Revert
    • Reflog
  2. Git Workflows

    • Feature branch workflow
    • Gitflow
    • Trunk-based development
    • Fork and pull model
  3. Git Internals

    • Objects and references
    • Git's data model
    • Hooks
    • Custom commands

Common Workflows

Individual Development

# Start a new feature
git checkout -b new-feature main

# Make changes
# ... edit files ...

# Stage and commit
git add .
git commit -m "Add new feature"

# Push to remote
git push -u origin new-feature

Team Collaboration

# Update your local copy
git checkout main
git pull

# Create feature branch
git checkout -b new-feature

# Make changes and commit
# ... edit files ...
git add .
git commit -m "Implement feature"

# Stay up to date with main
git fetch origin
git rebase origin/main

# Push to remote
git push -u origin new-feature

# Create pull request on GitHub

Resources

Reference Material

Recommended Reading

  • "Pro Git" by Scott Chacon and Ben Straub (free online)
  • "Git for Humans" by David Demaree

Online Tutorials

Tips for Success

  1. Commit Often: Make small, focused commits rather than large changes
  2. Write Good Messages: Clear commit messages help everyone understand changes
  3. Pull Before Push: Always update your local copy before pushing
  4. Use Branches: Keep your work organized with feature branches
  5. Learn From Mistakes: Git lets you recover from almost any mistake

Remember that Git has a learning curve, but it becomes second nature with practice. Don't be afraid to experiment - you can always use git reflog to find your way back if you get lost.

Explore the subdirectories for more detailed resources and examples on Git and GitHub usage.