Lesson 1: Introduction to Git

Learning Outcomes

  • Understand what Git is and why it's important for developers
  • Install Git on your computer
  • Configure Git with your user credentials
  • Understand the basic Git workflow

Why Git Matters

Git is the most widely used version control system in the world. It allows developers to:

  • Track changes to code over time
  • Collaborate with other developers on the same project
  • Revert to previous versions if something goes wrong
  • Work on different features simultaneously without conflicts

Understanding Git is essential for any software development career!

Git Introduction Video

Note: We're using a general Git introduction video here. The original link was to a text tutorial, but a video is more engaging for a presentation.

Setting Up Git

Installation Instructions

Windows/Mac

  • Visit git-scm.com
  • Download the latest version for your operating system
  • Run the installer with default settings

Chrome OS (2020+ devices)

  • Go to the Launcher
  • Search for "Linux" and click "Turn on"
  • Git is included in the Linux environment

Older Chrome OS devices

  • Install Termux from the Google Play Store
  • Open Termux and enter: pkg install git
  • Type y when prompted to confirm installation

Configuring Git

Setting Your Credentials

After installing Git, you need to configure your username and email address:

git config --global user.name "g11s1"
git config --global user.email "g11s1@ict.ru"

Important Note: Git credentials are set per computer, not per folder. If you change computers or someone else uses your computer, you'll need to check and possibly update the Git user credentials.

To check your current Git configuration:

git config --list

Exercise: Configure Git

  1. Open your terminal/command prompt
  2. Set your username: git config --global user.name "g11sX" (replace X with your student number)
  3. Set your email: git config --global user.email "g11sX@ict.ru"
  4. Verify your settings: git config --list

Lesson 2: Working with Local Repositories

Learning Outcomes

  • Create and initialize a local Git repository
  • Understand the basic Git workflow: add, commit, status
  • Fork and clone remote repositories
  • Make changes and push them to a remote repository

Why This Matters

Local repositories allow you to work on projects independently before sharing your changes. Understanding how to:

  • Create repositories
  • Track changes with commits
  • Work with remote repositories

These are fundamental skills for any development workflow!

Challenge 1: Local Repository

  1. Create a new folder called my-first-git-project
  2. Initialize it as a Git project: git init
  3. Open the folder in Sublime Text
  4. Create a basic README.md with an explanation of a project you'd like to do (use headers, lists, etc.)
  5. Add the file to staging: git add README.md
  6. Commit the changes: git commit -m "Added README file"
  7. Check the commit history: git log

Example README.md

# My First Git Project

## Project Description
This is a simple web application that will:
- Display current weather information
- Allow users to search for weather by city
- Show a 5-day forecast

## Technologies Used
- HTML
- CSS
- JavaScript
- Weather API

Challenge 2: Fork and Clone Repository

Forking a Repository

  1. Go to the example repository: https://gitea.techshare.cc/technolyceum/g11-m2.git
  2. Click the "Fork" button to create your own copy

Cloning to Your Local Environment

  1. Open your terminal/command tool
  2. Navigate to your projects folder: cd projects
  3. Clone your forked repository: git clone [your-forked-repo-url]
  4. Navigate into the new folder: cd [repository-name]

Making and Pushing Changes

  1. Make changes to the index.html file
  2. Stage your changes: git add .
  3. Check status: git status
  4. Commit changes: git commit -m "Changed index file"
  5. Push to remote: git push -u origin master
  6. Review your changes on the remote repository website

Lesson 3: Collaboration with Git

Learning Outcomes

  • Add collaborators to a GitHub repository
  • Clone and work on a collaborator's repository
  • Understand how to push changes and view differences
  • Use Git commands to compare changes between versions

Why Collaboration Matters

Most software development happens in teams. Git enables:

  • Multiple developers to work on the same codebase
  • Clear tracking of who made what changes
  • Managing contributions from different team members
  • Resolving conflicts when changes overlap

These collaboration skills are essential for real-world development!

Adding Collaborators

Step 1: Pair Up

Find a partner for this exercise - either a classmate or mentor.

Step 2: Add Collaborator in GitHub

  1. Navigate to your project in GitHub
  2. Click on the 'Settings' tab
  3. Select 'Collaborators' from the left menu
  4. Click 'Add people' and search for your partner's GitHub username
  5. Send the collaboration invitation

Note: The exact steps may vary slightly depending on the Git platform (GitHub, GitLab, Gitea, etc.), but the concept is the same.

Collaboration Exercise

Step 3: Clone and Modify

  1. Your partner should clone your repository: git clone [your-repo-url]
  2. Create a new folder for this project if needed
  3. Give your partner a simple "spec" - a small change to make in your project
  4. Your partner makes the change, then:
    git add .
    git commit -m "Made requested change"
    git push origin master

Step 4: Review Changes

  1. Pull the latest changes: git pull origin master
  2. View recent changes: git diff HEAD
  3. Compare with previous version: git diff HEAD~1
  4. Check the commit history on GitHub to see your partner's contribution

Step 5: Reverse Roles

Now repeat the process with roles reversed - you become the collaborator on your partner's repository.

Git Commands Summary

Basic Git Workflow

# Initialize a new repository
git init

# Clone an existing repository
git clone [repository-url]

# Check status of files
git status

# Add files to staging
git add [filename]
git add . # Add all files

# Commit changes
git commit -m "Commit message"

# Push to remote repository
git push origin master

# Pull latest changes
git pull origin master

# View commit history
git log

# Compare changes
git diff
git diff HEAD
git diff HEAD~1

Congratulations!

You've completed the 3-lesson Git fundamentals course. You now have the basic skills to use Git for version control and collaboration!