Skip to content

Session 2 Git and GitHub

Maximiliano Militzer edited this page Apr 7, 2025 · 1 revision

Session 2: Git and GitHub

Overview

In this session, we'll learn about version control systems, specifically Git, and how to use GitHub for collaborative software development. These tools are essential for modern software development and are used by nearly every professional developer.

Learning Objectives

  • Understand what version control is and why it's important
  • Learn basic Git commands and workflow
  • Create a GitHub account and repository
  • Understand branching, merging, and pull requests
  • Learn how to collaborate with others using Git and GitHub

Topics Covered

1. What is Version Control?

Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. It allows multiple people to work on a project simultaneously without overwriting each other's changes.

2. Introduction to Git

Git is a distributed version control system that tracks changes in any set of computer files. It was created by Linus Torvalds in 2005 for the development of the Linux kernel.

Key Concepts:

  • Repository (repo): A storage location where your project files and their revision history are kept
  • Commit: A snapshot of your repository at a specific point in time
  • Branch: A parallel version of the repository that doesn't affect the main branch
  • Merge: The act of integrating changes from one branch into another

3. Basic Git Commands

# Initialize a new Git repository
git init

# Check the status of your repository
git status

# Add files to the staging area
git add filename
git add .  # Add all files

# Commit changes with a message
git commit -m "Your message here"

# View commit history
git log

4. GitHub Basics

GitHub is a web-based platform that uses Git for version control. It provides additional features like:

  • Hosting repositories online
  • Issue tracking
  • Pull requests
  • Project management
  • Code reviews

Getting Started with GitHub:

  • Creating an account
  • Creating a new repository
  • Connecting your local repository to GitHub
  • Pushing your code to GitHub
# Connect local repository to GitHub
git remote add origin https://github.com/yourusername/your-repo-name.git

# Push your code to GitHub
git push -u origin main

5. Collaborative Workflow

  • Forking a repository
  • Cloning a repository
  • Creating branches
  • Making pull requests
  • Reviewing and merging code
# Clone a repository
git clone https://github.com/username/repository.git

# Create and switch to a new branch
git checkout -b feature-branch

# Push branch to GitHub
git push origin feature-branch

Practice Exercises

  1. Create a GitHub account and set up your profile
  2. Create a new repository and add a README.md file
  3. Make changes locally and push them to GitHub
  4. Create a branch, make changes, and create a pull request
  5. Collaborate with a classmate on a simple project

Additional Resources

Next Steps

Now that you understand Git and GitHub, you're ready to move on to Session 3: HTML and CSS where you'll learn how to create and style web pages.

Clone this wiki locally