Introduction to GitHub
GitHub is the world's largest platform for hosting and collaborating on Git repositories. While Git is the version control system that runs on your computer, GitHub is a cloud-based hosting service that brings social coding, collaboration tools, and project management to your Git workflows.
What is GitHub?
GitHub is much more than just a place to store code:
GitHub provides:
- Remote Git repository hosting
- Web-based Git repository visualization
- Collaboration tools (pull requests, code review)
- Project management (issues, projects, milestones)
- Documentation hosting (wikis, README files)
- Continuous integration/deployment (GitHub Actions)
- Package registry (npm, Docker, Maven, etc.)
- Security features (Dependabot, code scanning)
- Community features (stars, forks, discussions)
Fun Fact: GitHub hosts over 100 million repositories and has more than 90 million developers worldwide. It was acquired by Microsoft in 2018 for $7.5 billion.
GitHub vs Git: Understanding the Difference
Many beginners confuse Git and GitHub. Here's how they differ:
Git:
- Version control system (software)
- Runs locally on your computer
- Command-line tool
- Created by Linus Torvalds (2005)
- Free and open source
- Works without internet
GitHub:
- Web-based hosting service for Git
- Runs on GitHub's servers (cloud)
- Web interface + Git commands
- Founded by Tom Preston-Werner (2008)
- Free tier + paid plans
- Requires internet connection
Analogy: Think of Git as Microsoft Word (software that creates documents) and GitHub as Google Drive (service that stores and shares those documents online).
Why Use GitHub?
GitHub offers numerous benefits for individual developers and teams:
For Individual Developers:
✓ Portfolio showcase for potential employers
✓ Backup of your code in the cloud
✓ Learn from millions of open source projects
✓ Contribute to open source software
✓ Build a professional reputation
For Teams:
✓ Centralized code repository
✓ Built-in code review process
✓ Issue tracking and project management
✓ Automated workflows with Actions
✓ Team collaboration tools
✓ Access control and permissions
Creating a GitHub Account
Getting started with GitHub is straightforward:
Steps to create an account:
1. Visit https://github.com
2. Click "Sign up" in the top right
3. Enter your email address
4. Create a password (use a strong one!)
5. Choose a username (this will be public)
6. Verify you're not a robot
7. Check your email for verification code
8. Complete your profile (optional but recommended)
Username Tips:
- Use a professional username (employers will see it)
- Keep it simple and memorable
- Match other professional profiles (LinkedIn, etc.)
- Examples: john-smith, jsmith-dev, johnsmith
Pro Tip: Your GitHub username becomes part of your repository URLs (github.com/username/repo), so choose wisely. You can change it later, but it may break links.
GitHub Pricing and Plans
GitHub offers different plans for various needs:
GitHub Free:
- Unlimited public repositories
- Unlimited private repositories
- 2,000 Actions minutes/month
- 500 MB package storage
- Community support
- Perfect for individuals and small teams
GitHub Pro ($4/month):
- Everything in Free
- 3,000 Actions minutes/month
- 2 GB package storage
- Advanced tools and insights
- Pages and Wikis for private repos
GitHub Team ($4/user/month):
- Everything in Pro
- Team access controls
- Multiple reviewers in pull requests
- Draft pull requests
GitHub Enterprise:
- Self-hosted or cloud
- Advanced security features
- Compliance certifications
- Dedicated support
Note: Most developers start with the free plan, which is more than sufficient for learning, personal projects, and even professional work.
Setting Up SSH Keys
SSH keys provide a secure way to authenticate with GitHub without entering passwords:
1. Check for existing SSH keys:
ls -al ~/.ssh
# Look for id_rsa.pub or id_ed25519.pub
2. Generate new SSH key (if needed):
ssh-keygen -t ed25519 -C "your_email@example.com"
# For older systems:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
3. Start SSH agent:
eval "$(ssh-agent -s)"
4. Add SSH key to agent:
ssh-add ~/.ssh/id_ed25519
5. Copy public key to clipboard:
# macOS:
pbcopy < ~/.ssh/id_ed25519.pub
# Linux:
cat ~/.ssh/id_ed25519.pub
# Then manually copy the output
# Windows (Git Bash):
clip < ~/.ssh/id_ed25519.pub
6. Add SSH key to GitHub:
1. Go to GitHub.com and log in
2. Click your profile photo → Settings
3. Click "SSH and GPG keys" in sidebar
4. Click "New SSH key"
5. Give it a title (e.g., "My Laptop")
6. Paste your public key
7. Click "Add SSH key"
7. Test SSH connection:
ssh -T git@github.com
# Success message:
Hi username! You've successfully authenticated...
Personal Access Tokens (PAT)
Personal Access Tokens are an alternative to SSH for HTTPS authentication:
When to use PATs:
- Authenticating with HTTPS instead of SSH
- Using GitHub API
- Accessing GitHub from scripts/tools
- When SSH is blocked by firewall
Creating a Personal Access Token:
1. GitHub.com → Settings → Developer settings
2. Click "Personal access tokens" → "Tokens (classic)"
3. Click "Generate new token" → "Generate new token (classic)"
4. Give token a descriptive name
5. Set expiration (30/60/90 days or custom)
6. Select scopes (permissions):
- repo: Full control of private repositories
- workflow: Update GitHub Actions workflows
- admin:org: Manage organization
7. Click "Generate token"
8. Copy token immediately (you won't see it again!)
Using the token:
# When prompted for password, use token instead
git clone https://github.com/username/repo.git
Username: your_username
Password: paste_your_token_here
Security Warning: Treat Personal Access Tokens like passwords. Never commit them to repositories or share them. Store them securely (password manager recommended).
Enabling Two-Factor Authentication (2FA)
2FA adds an extra layer of security to your GitHub account:
Setting up 2FA:
1. GitHub.com → Settings → Password and authentication
2. Click "Enable two-factor authentication"
3. Choose authentication method:
- Authenticator app (recommended)
- SMS text messages
Using an authenticator app:
1. Download an app (Authy, Google Authenticator, 1Password)
2. Scan QR code with the app
3. Enter 6-digit code to verify
4. Save recovery codes in a safe place!
Important notes:
- Save recovery codes! (Print or password manager)
- You'll need 2FA code each time you log in
- PATs still work with 2FA enabled
- Some Git operations require PAT instead of password
Best Practice: Enable 2FA immediately after creating your account. It significantly increases account security and is required for many organizations.
Configuring Git for GitHub
Configure Git with your GitHub account information:
# Set your name (use your GitHub name)
git config --global user.name "Your Name"
# Set your email (use your GitHub email)
git config --global user.email "your_email@example.com"
# Set default branch name to main
git config --global init.defaultBranch main
# Set default editor
git config --global core.editor "code --wait" # VS Code
git config --global core.editor "vim" # Vim
# Verify configuration
git config --list
GitHub Ecosystem and Alternatives
While GitHub is the most popular, there are alternatives:
GitHub:
- Most popular (100M+ repos)
- Best for open source
- Excellent community features
- Owned by Microsoft
GitLab:
- Strong DevOps features
- Built-in CI/CD
- Self-hosting option
- Popular in enterprises
Bitbucket:
- Atlassian ecosystem (Jira integration)
- Good for private repositories
- Popular in corporate environments
Other platforms:
- Gitea (self-hosted, lightweight)
- SourceForge (legacy platform)
- Azure DevOps (Microsoft enterprise)
GitHub Desktop and CLI
GitHub provides additional tools beyond the web interface:
GitHub Desktop:
- Visual Git client
- Simplifies Git operations
- Great for beginners
- Available for Windows and macOS
- Download: desktop.github.com
GitHub CLI (gh):
- Command-line tool for GitHub
- Manage repos, issues, PRs from terminal
- Install: cli.github.com
# Example GitHub CLI commands:
gh repo create my-project --public
gh issue list
gh pr create --title "Add feature"
gh pr merge 123
Getting Started Exercise:
Set up your GitHub account:
- Create a GitHub account (if you don't have one)
- Complete your profile with a bio and profile picture
- Generate SSH keys and add to GitHub
- Test SSH connection with
ssh -T git@github.com
- Enable two-factor authentication
- Configure Git with your GitHub name and email
- Explore trending repositories on GitHub
- Star an interesting repository
Bonus: Install GitHub Desktop or GitHub CLI and explore its features.
Summary
In this lesson, you learned:
- GitHub is a cloud hosting service for Git repositories with collaboration tools
- Git is the version control software; GitHub is the hosting platform
- GitHub offers free plans suitable for most developers
- SSH keys and Personal Access Tokens provide secure authentication
- Two-factor authentication significantly improves account security
- GitHub provides web interface, desktop app, and CLI tools
- The platform includes project management, CI/CD, and community features
Next Up: In the next lesson, we'll learn how to create and manage repositories on GitHub, including README files, licenses, and repository settings!