Skip to main content

GitHub Basic

Introduction to GitHub

What is GitHub?

GitHub is like a social media platform for programmers and their code. Just as you share photos on Instagram or updates on Facebook, developers share their code projects on GitHub.

Key Points:

  • Web-based platform that uses Git (a DVCS) for version control
  • Cloud storage for your code projects
  • Collaboration tools for working with others
  • Free and paid plans available
  • Most popular platform for open-source projects

GitHub vs Git: What's the Difference?

Git is like a notebook you keep at home — you write, erase, and rewrite your ideas. GitHub is like publishing that notebook online so others can read it, suggest edits, or even contribute.

  • Git: The version control system (software)
  • GitHub: A web service that hosts Git repositories online

Or..

  • Think of Git as the engine.
  • GitHub is the garage that stores the car (your project).

Why Use GitHub?

For Students:

  • Store your projects safely online
  • Show your work to potential employers
  • Collaborate on group projects
  • Learn from others' code
  • Build a portfolio of your work

For Professionals:

  • Industry standard for software development
  • Backup and sync code across devices
  • Collaborate with team members
  • Track bugs and feature requests
  • Deploy applications

Getting Started with GitHub

Step-by-Step Account Creation:

  1. Visit GitHub.com

  2. Sign Up

    • Click "Sign up" button
    • Choose a username (this will be part of your profile URL)
    • Enter your email address
    • Create a strong password
    • Verify you're human (solve the puzzle)
  3. Choose Your Plan

    • Select "Free" for personal use
    • Free accounts get unlimited public and private repositories
  4. Verify Your Email

    • Check your email inbox
    • Click the verification link
  5. Complete Your Profile

    • Add a profile picture
    • Write a short bio
    • Add your location and website if desired

Instructor will do a live demo


GitHub Fundamentals

Understanding the GitHub Interface

When you log into GitHub, you'll see several key areas:

Dashboard (Home Page):

  • Shows activity from people you follow
  • Displays your recent repositories
  • Shows contribution activity (green squares)

insert a sample picture

Navigation Bar:

  • Pull requests: Changes you want to merge
  • Issues: Bugs or feature requests
  • Marketplace: Tools and applications
  • Explore: Discover new projects

insert a sample picture

Profile Page:

  • Your repositories
  • Contribution graph
  • Activity overview
  • Followers and following

insert a sample picture

Basic GitHub Terminology

Repository (Repo): Think of this as a folder that contains your entire project, including all files and the complete history of changes.

Username: Your unique identifier on GitHub (e.g., @johnsmith)

Organization: A shared account where multiple people can collaborate on projects

Fork: Making your own copy of someone else's project

Star: Like bookmarking a project you find interesting

Watch: Get notifications about activity in a repository

Gist: A simple way to share code snippets

Live demo for the above

Creating Your First Repository

Step-by-Step Process:

  1. Start Creating

    • Click the "+" icon in the top right corner
    • Select "New repository"
  2. Repository Details

    • Repository name: Choose something descriptive (e.g., "my-first-website")
    • Description: Brief explanation of what this project does
    • Visibility: Choose "Public" (anyone can see) or "Private" (only you can see)
  3. Initialize Repository

    • ✅ Check "Add a README file"
    • Choose a license (MIT License is good for beginners)
    • Choose .gitignore template if needed
  4. Create Repository

    • Click "Create repository"
    • Congratulations! You've created your first repo

live demo

Example Repository Setup:

Repository name: my-study-notes
Description: Collection of my class notes and study materials for university
Visibility: Public
✅ Initialize with README
License: MIT License

Core Concepts: Repository, Commit, Branch

Repository Deep Dive

A repository is like a project folder, but much more powerful. It contains:

Files and Folders: Your actual project content History: Complete record of all changes ever made Branches: Different versions of your project Issues: Bug reports and feature requests Wiki: Documentation pages

Repository Structure Example:

my-research-project/
├── research-proposal.md (main project proposal)
├── literature-review.md (review of existing research)
├── methodology.md (research methods)
├── data/ (folder for research data)
│ ├── survey-results.csv
│ └── interview-notes.txt
├── images/ (folder for charts and graphs)
│ ├── chart1.png
│ └── diagram.jpg
├── README.md (project description)
└── LICENSE (usage permissions)

Understanding Commits

What is a Commit? A commit is like taking a snapshot of your project at a specific moment in time. Each commit records:

  • What files changed
  • What exactly changed in those files
  • Who made the changes
  • When the changes were made
  • A message describing why the changes were made

Commit Message Best Practices:

  • Be clear and descriptive
  • Explain the "why" not just the "what"

Good Commit Messages:

  • ✅ "Add contact form to homepage"
  • ✅ "Fix navigation menu on mobile devices"
  • ✅ "Update README with installation instructions"

Poor Commit Messages:

  • ❌ "Fixed stuff"
  • ❌ "Update"
  • ❌ "asdf"

Making Your First Commit

Step-by-Step Process:

  1. Navigate to Your Repository

    • Go to your repository page on GitHub
    • You should see your README.md file
  2. Edit a File

    • Click on README.md
    • Click the pencil icon (Edit this file)
    • Add some text about yourself:
    # My Study Notes Repository

    Hello! This is my first GitHub repository where I'll organize my study materials.
    I'm learning about version control systems and digital collaboration.

    ## About Me
    - Student at [Your School Name]
    - Major: [Your Major]
    - Interested in organizing and sharing knowledge

    ## What I'll Store Here
    - Class notes from lectures
    - Study guides for exams
    - Research project materials
    - Group project documents
  3. Commit Your Changes

    • Scroll down to "Commit changes" section
    • Add commit message: "Add personal information and academic goals to README"
    • Add description: "Added basic information about myself, my major, and my learning objectives for this course"
    • Click "Commit changes"
  4. View Your Commit

    • You'll see your changes are now live
    • Click on the commit history to see your commit

live demo

Understanding Branches

What is a Branch? Think of branches like parallel universes of your project. You can work on different features or experiments without affecting the main version.

Real-World Analogy: Imagine you're writing a story. The main branch is your original story. You create a branch called "alternate-ending" to try out a different conclusion. You can work on this alternate ending without changing your original story. Later, you can decide which ending you prefer.

Default Branch:

  • main: The primary branch (like the trunk of a tree)
  • All other branches stem from main
  • This is the "official" version of your project

Common Branch Names:

  • feature/study-schedule (adding a study schedule document)
  • bugfix/typos-in-notes (fixing spelling errors in notes)
  • experiment/new-format (trying out a new note-taking format)

Creating and Working with Branches

Step-by-Step Branch Creation:

  1. Create a New Branch

    • In your repository, click the branch dropdown (shows "main")
    • Type a new branch name: "add-study-schedule"
    • Click "Create branch: add-study-schedule"
  2. Work on Your Branch

    • You're now on the new branch (notice the branch name changed)
    • Create a new file: Click "Add file" → "Create new file"
    • Name it "study-schedule.md"
    • Add your study schedule:
    # My Weekly Study Schedule

    ## Monday
    - 9:00 AM - 11:00 AM: Mathematics Review
    - 2:00 PM - 4:00 PM: History Reading
    - 7:00 PM - 8:00 PM: Science Lab Report

    ## Tuesday
    - 10:00 AM - 12:00 PM: English Literature Analysis
    - 3:00 PM - 5:00 PM: Group Project Meeting
    - 8:00 PM - 9:00 PM: Review Notes

    ## Wednesday
    - 9:00 AM - 11:00 AM: Mathematics Practice Problems
    - 1:00 PM - 3:00 PM: Research for Term Paper
    - 6:00 PM - 7:00 PM: Study Group Session
  3. Commit on Your Branch

    • Add commit message: "Add weekly study schedule"
    • Click "Commit new file"
  4. Switch Between Branches

    • Use the branch dropdown to switch back to "main"
    • Notice that study-schedule.md doesn't exist on main branch
    • Switch back to "add-study-schedule" branch
    • The study-schedule.md file is back!

live demo


Issue Tracking

What are Issues?

Issues are GitHub's way of tracking bugs, feature requests, questions, and tasks. Think of them as a to-do list for your project that everyone can see and contribute to.

Types of Issues:

  • Bug Reports: Something is broken and needs fixing
  • Feature Requests: Ideas for new functionality
  • Questions: Need help or clarification
  • Tasks: Work that needs to be done
  • Documentation: Updates needed to docs

Anatomy of a Good Issue

Essential Components:

  1. Clear Title: Summarizes the issue in one line
  2. Detailed Description: Explains the problem or request
  3. Steps to Reproduce: For bugs, how to recreate the problem
  4. Expected Behavior: What should happen
  5. Actual Behavior: What actually happens
  6. Screenshots: Visual evidence when helpful
  7. Labels: Categories to organize issues
  8. Assignees: Who will work on this

Creating Your First Issue

Step-by-Step Issue Creation:

  1. Navigate to Issues

    • Go to your repository
    • Click on "Issues" tab
    • Click "New issue"
  2. Write a Bug Report

    Title: Study schedule file has formatting issues

    Description:
    The study-schedule.md file is not displaying properly when viewed on GitHub. The formatting appears broken and some text is not showing correctly.

    Steps to Reproduce:
    1. Go to the main branch of the repository
    2. Click on "study-schedule.md" file
    3. Observe the formatting display

    Expected Behavior:
    The study schedule should display as a well-formatted table with clear time slots and subjects for each day of the week.

    Actual Behavior:
    The schedule appears as plain text without proper markdown formatting, making it difficult to read and understand.

    Suggested Fix:
    Use proper markdown table formatting to make the schedule more readable and organized.
  3. Add Labels

    • Click on "Labels" in the right sidebar
    • Add "bug" label
    • Add "good first issue" if it's easy to fix
  4. Submit the Issue

    • Click "Submit new issue"
    • The issue is now tracked and visible to everyone

Working with Issues

Issue Lifecycle:

  1. Open: Issue is created and needs attention
  2. Assigned: Someone is working on it
  3. In Progress: Work has started
  4. Closed: Issue is resolved or no longer relevant

Assigning Issues:

  • Click on "Assignees" in the right sidebar
  • Select yourself or a team member
  • This shows who's responsible for the issue

Using Labels:

  • bug: Something is broken
  • enhancement: New feature or improvement
  • documentation: Documentation needs work
  • good first issue: Easy for beginners
  • help wanted: Looking for contributors
  • priority-high: Urgent issues

Commenting in GitHub

What is a Comment in GitHub?

A comment in GitHub is a note you can write to explain something, ask a question, or give feedback.
It helps you remember what you were doing and helps others understand your work more easily later — even if that “other person” is future you!

Commenting is not just about talking — it's about making your work easier to understand, track, and improve.


Where Can You Add Comments in GitHub?

GitHub lets you comment in several places. Here are the most common types for beginners:

1. Issue Comments

These are notes inside an issue — a place where you describe something that needs to be done, like a bug or a task.

Example:
You create an issue: “Need to fix typo in recipe.”
Then you comment: “The word 'tommato' should be 'tomato' in pasta.txt.”

2. Commit Comments

These are comments added to a specific commit (a saved version of your work).
Use them to explain or clarify what was done in that version.

Example:
In a commit where you added a new recipe, you comment:
“Added chocolate cake recipe — still needs baking time.”

3. Code Comments (Line Comments)

These are added to specific lines of code or text in a file.
You can do this when viewing a file or during a code review.

Example:
You click on line 5 of cake.txt and comment:
“Consider listing the number of eggs required.”


How to Add Comments in GitHub (Step-by-Step)

📝 To Add an Issue Comment:

  1. Go to the "Issues" tab in your repository.
  2. Click on an issue (or create one).
  3. Scroll down to the comment box.
  4. Type your note and click "Comment".

📝 To Comment on a Commit:

  1. Go to the "Commits" tab (usually under "Code").
  2. Click on a commit.
  3. Click on the "..." beside a file, then click "Add a comment".
  4. Type your comment and click "Comment".

📝 To Comment on a Specific Line of Code:

  1. Open a file in the repository.
  2. Hover next to a line number and click the "+" icon.
  3. Type your comment in the box that appears.
  4. Click "Add single comment".

Good Commenting Practices

Commenting in GitHub is not just about what you say — it's about how you say it.

✅ Be Clear and Helpful

  • Line 8: This sentence is hard to follow. Consider rewording.
  • Great start! Maybe add ingredients list before instructions.

✅ Be Polite and Encouraging

  • Nice work! Just a small suggestion for improvement below.
  • ❌ Avoid saying things like "This is bad" — instead, explain what could be better.

✅ Be Specific

  • The image isn’t loading because the file name is spelled 'imgage.jpg' instead of 'image.jpg'.
  • ❌ Avoid vague comments like "It’s broken" or "Fix this."

Key Points Summary

Best Practices Checklist

Repository Management:

  • ✅ Use descriptive repository names
  • ✅ Write clear README files
  • ✅ Choose appropriate licenses
  • ✅ Use .gitignore for unnecessary files
  • ✅ Keep repositories organized

Commit Practices:

  • ✅ Write clear, descriptive commit messages
  • ✅ Make small, focused commits
  • ✅ Commit related changes together
  • ✅ Test before committing

Branching Strategy:

  • ✅ Create branches for new features
  • ✅ Use descriptive branch names
  • ✅ Keep branches focused on single features
  • ✅ Delete merged branches
  • ✅ Regularly sync with main branch

Issue Tracking:

  • ✅ Create issues for bugs and features
  • ✅ Use descriptive titles and descriptions
  • ✅ Apply appropriate labels
  • ✅ Assign issues to team members
  • ✅ Link issues to pull requests
  • ✅ Close issues when resolved

Common Mistakes to Avoid

Don't Do This:

  • ❌ Commit directly to main branch without review
  • ❌ Write vague commit messages like "updated stuff"
  • ❌ Share personal information or sensitive data in public repositories
  • ❌ Leave assignment answers or exam materials in public repositories

Do This Instead:

  • ✅ Write clear, descriptive commit messages
  • ✅ Break large projects into smaller, manageable pieces
  • ✅ Learn GitHub features gradually and ask for help when needed
  • ✅ Use private repositories for sensitive academic work

Quick Reference Commands

Essential GitHub Actions (Web Interface):

Repository Management:

  • Create new repository: Click "+" → "New repository"
  • Fork repository: Click "Fork" button on any repo
  • Clone repository: Click "Code" → Copy URL
  • Watch repository: Click "Watch" → Choose notification level

File Management:

  • Create file: "Add file" → "Create new file"
  • Edit file: Click filename → Click pencil icon
  • Delete file: Click filename → Click trash icon
  • Upload files: "Add file" → "Upload files"

Branch Operations:

  • Create branch: Branch dropdown → Type new name → "Create branch"
  • Switch branch: Use branch dropdown menu
  • Compare branches: "Compare" button or pull request interface