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
- Open your terminal/command prompt
- Set your username:
git config --global user.name "g11sX" (replace X with your student number)
- Set your email:
git config --global user.email "g11sX@ict.ru"
- 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
- Create a new folder called
my-first-git-project
- Initialize it as a Git project:
git init
- Open the folder in Sublime Text
- Create a basic
README.md with an explanation of a project you'd like to do (use headers, lists, etc.)
- Add the file to staging:
git add README.md
- Commit the changes:
git commit -m "Added README file"
- 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
- Go to the example repository:
https://gitea.techshare.cc/technolyceum/g11-m2.git
- Click the "Fork" button to create your own copy
Cloning to Your Local Environment
- Open your terminal/command tool
- Navigate to your projects folder:
cd projects
- Clone your forked repository:
git clone [your-forked-repo-url]
- Navigate into the new folder:
cd [repository-name]
Making and Pushing Changes
- Make changes to the
index.html file
- Stage your changes:
git add .
- Check status:
git status
- Commit changes:
git commit -m "Changed index file"
- Push to remote:
git push -u origin master
- 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
- Navigate to your project in GitHub
- Click on the 'Settings' tab
- Select 'Collaborators' from the left menu
- Click 'Add people' and search for your partner's GitHub username
- 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
- Your partner should clone your repository:
git clone [your-repo-url]
- Create a new folder for this project if needed
- Give your partner a simple "spec" - a small change to make in your project
- Your partner makes the change, then:
git add .
git commit -m "Made requested change"
git push origin master
Step 4: Review Changes
- Pull the latest changes:
git pull origin master
- View recent changes:
git diff HEAD
- Compare with previous version:
git diff HEAD~1
- 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!