Github Guide

What is Github?

GitHub is a platform where developers and teams around the world collaborate on code projects, track changes, and manage software development—all in one place.

At its core, GitHub is:
  • A code hosting platform based on Git, a powerful version control system
  • A tool that allows developers to work together, no matter where they are
  • A home for open-source projects, meaning anyone can contribute to public code
What You Can Do on GitHub
  • Create repositories (aka "repos") to store and organize your project files
  • Track changes made to code over time (version control)
  • Collaborate via pull requests, where others suggest edits or improvements
  • Issue tracking to manage bugs, tasks, and features
  • Host documentation and even full websites with GitHub Pages
Who Uses GitHub?
  • Individual coders sharing cool side projects
  • Startups building MVPs
  • Giant companies maintaining mission-critical software
  • Educators and students learning how to code and contribute
What's the difference between Git and Github?

Git is a version control system created by Linus Torvalds (yep, the same guy behind Linux), whereas Github is a cloud-based platform that hosts Git repositories.

Github Quick Start

  1. Download Git:

    Go to https://git-scm.com/downloads and download Git for your OS (Windows, macOS, Linux).
  2. Run the installer:

    On Windows, leave most options as default unless you know what you’re doing.
  3. Check installation:

    Type this in the command line and press enter:
    
    git --version    
    
    
    You should see something like `git version 2.xx.x`.
  4. Configure Git

    Before using Git, tell it who you are (this info will be attached to commits), type this into the command line, replacing the example with your name and email:
    
    git config --global user.name "Your Name"
    git config --global user.email "youremail@example.com"
    
    
  5. Create a new GitHub repo

    ✅ Go to https://github.com, log in, and click New repository. ✅ Give it a name (e.g., `my-first-repo`), optionally a description.
    ✅ Choose Public or Private.
    ✅ Don’t initialize with README yet if you want to push an existing local repo.
  6. Set up a local repo

    ✅ Create a new folder on your computer:
    
    mkdir my-first-repo
    cd my-first-repo
    
    
    ✅ Initialize it as a Git repo:
    
    git init
    
    
    This creates a .git directory — the local database where Git tracks everything.
  7. Add your first file

    Create a file, for example:
    
    echo "# My First Repo" >  README.md
    
    
  8. Stage changes

    ✅ Check which files are new/modified:
    
    git status
    
    
    ✅ Stage your file:
    
    git add README.md
    
    
    ✅ Or stage everything at once:
    
    git add .
    
    
  9. Commit changes

    ✅ Commit with a message:
    
    git commit -m "Initial commit: add README"
    
    
  10. Connect to GitHub

    ✅ Copy your GitHub repo’s URL (HTTPS is easiest), e.g.:
    
    https://github.com/yourusername/my-first-repo.git
    
    
    ✅ Add it as a remote:
    
    git remote add origin https://github.com/yourusername/my-first-repo.git
    
    
    ✅ Push your branch (`main` or `master` depending on your Git version):
    
    git branch -M main  # sets branch name to main
    git push -u origin main
    
    
  11. Create and switch to a new branch

    ✅ Create a branch named `feature1`:
      
    git checkout -b feature1
    
    
    This creates the branch and switches to it.
  12. 🔨Work on your branch

    ✅ Make changes, stage them:
     
    git add .
    
    
    ✅ Commit them:
    
    git commit -m "Add feature 1"
    
    
  13. Switch between branches

    ✅ Go back to main:
    
    git checkout main
    
    
    ✅ Return to your feature branch:
    
    git checkout feature1
    
    
  14. Merge your branch into main

    ✅ Switch to main:
    
    git checkout main
    
    
    ✅ Merge feature1 into main:
    
    git merge feature1
    
    
    💡 If there are conflicts, Git will tell you to resolve them manually.

    ✅ Push updated main to GitHub:
    
    git push
    
    
  15. Contribute to someone else’s repo (fork & PR)

    Fork the repo on GitHub (click the “Fork” button on their repo page).
    Clone your fork locally:
    
    git clone https://github.com/yourusername/their-repo.git
    cd their-repo
    
    
    Create a branch for your changes:
    
    git checkout -b fix-issue-42
    
    
    Make changes, stage, commit:
    
    git add .
    git commit -m "Fix issue #42: correct typo"
    
    
    Push the branch to your fork on GitHub:
    
    git push origin fix-issue-42
    
    
    ✅ On GitHub, go to your fork and you’ll see a Compare & pull request button. Click it to submit your PR.
  16. View commit logs

    ✅ Simple log:
    
    git log
    
    
    ✅ Compact one-line log:
    
    git log --oneline
    
    
    ✅ View log with graphical branch history:
    
    git log --oneline --graph --all
    
    
  17. Bonus: Handling conflicts

    ✅ If you try to merge or pull and there are conflicting changes, Git will mark them in your files with these markers:
    
    >>>>>>  ======= <<<<<<  
    
    
    ✅ Edit the files manually to keep what you want, remove the conflict markers, then:
    
    git add conflictedfile.txt
    git commit
    
    
  18. Common useful commands

    ✅ See current branch:
    
    git branch
    
    
    ✅ Delete a branch (after merging):
    
    git branch -d feature1
    
    
    ✅ Pull latest changes from origin:
    
    git pull
    
    
    ✅ See remote branches:
    
    git remote -v
    
    

🎯 From the school of hard-knocks

My advice is to commit your code often! If you lose power, your battery dies or you accidently erase hours of coding, you'll be glad you took my advice and committed your code to your remote repo.

📺 Learn by watching YouTube Videos

Git & Github Crash Course 2025 Traversy Media: 49 min

Github for Beginners 2025 Corbin Brown: 10min

Git, Github and Github Desktop 2023 Coder Coder: 22 min