Hands-on Lab TP1 — Installation & First Repository
Hands-on Lab 45 min Module 00
Objectives
By the end of this lab, you will have:
- Git installed and verified on your machine
- Your identity configured (name + email)
- An SSH key generated and added to GitHub
- Your first repository created
- Your first commit made
- A
.gitignorefile configured - The result pushed to GitHub
Part 1: Verify Installation
Open your terminal and run:
# Check Git version (must be 2.x.x)
git --version
# Check GitHub CLI
gh --version
# Check SSH agent is running
ssh-agent -s
Expected results
You should see version numbers for each command. If any fails, go back to the installation lesson.
Part 2: Configure Git
# Configure your identity (replace with your real info)
git config --global user.name "Your Full Name"
git config --global user.email "your.email@example.com"
# Configure VS Code as editor
git config --global core.editor "code --wait"
# Set 'main' as default branch
git config --global init.defaultBranch main
# Configure line endings
# Windows:
git config --global core.autocrlf true
# macOS/Linux:
git config --global core.autocrlf input
# Add useful aliases
git config --global alias.lg "log --oneline --graph --decorate --all"
git config --global alias.st status
# Verify your configuration
git config --list
Expected output of git config --list:
user.name=Your Full Name
user.email=your.email@example.com
core.editor=code --wait
init.defaultbranch=main
core.autocrlf=true (or input)
alias.lg=log --oneline --graph --decorate --all
alias.st=status
Part 3: SSH Key Setup
# Generate SSH key (replace with your email)
ssh-keygen -t ed25519 -C "your.email@example.com"
# → Press Enter for all prompts (or add a passphrase for more security)
# Start SSH agent
eval "$(ssh-agent -s)"
# Add key to agent
ssh-add ~/.ssh/id_ed25519
# Display your public key to copy it
cat ~/.ssh/id_ed25519.pub
On GitHub:
- Go to github.com/settings/keys
- Click New SSH key
- Title:
My Laptop 2026 - Paste the key content
- Click Add SSH key
Test the connection:
ssh -T git@github.com
# Expected: Hi your-username! You've successfully authenticated...
Part 4: Create Your First Project
# Create the project folder
mkdir git-tp1-first-project
cd git-tp1-first-project
# Initialize Git
git init
# Verify the .git folder was created
ls -la
Create Project Files
Create a README.md file with this content:
# My First Git Project
A project created during the Git & GitHub course at InSkillBoost.
## Author
Your Name — your.email@example.com
## Description
This project demonstrates the basic concepts of Git:
- Repository initialization
- Staging and committing
- History management
Create a hello.py file:
def greet(name):
"""Greet a person by name."""
return f"Hello, {name}! Welcome to Git."
if __name__ == "__main__":
print(greet("World"))
print(greet("Git"))
Create a .gitignore file:
# Python
__pycache__/
*.pyc
*.pyo
venv/
.env
# OS
.DS_Store
Thumbs.db
# Editor
.vscode/
.idea/
*.swp
Part 5: Your First Commits
# Check initial status
git status
You should see 3 untracked files.
# Add README.md first
git add README.md
git status
# README.md should appear under "Changes to be committed"
# Make first commit
git commit -m "docs: add README with project description"
# Add the remaining files
git add hello.py .gitignore
git status
# Make second commit
git commit -m "feat: add hello.py and .gitignore"
# View history
git log
git lg # with the alias we created
Part 6: Push to GitHub
Create the Repository on GitHub
# Use GitHub CLI to create the repository
gh repo create git-tp1-first-project --public --description "TP1 - First Git Repository"
Or manually:
- Go to github.com/new
- Repository name:
git-tp1-first-project - Don't initialize with README (we already have one locally)
- Click Create repository
Link and Push
# Add the remote (replace with your GitHub username)
git remote add origin git@github.com:YOUR_USERNAME/git-tp1-first-project.git
# Push your commits
git push -u origin main
# Verify on GitHub
gh repo view --web
# Or open your browser to your GitHub repository
Validation Checklist
Verify each point before marking the lab complete:
-
git --versionshows version 2.x.x -
git config user.nameshows your name -
git config user.emailshows your email -
ssh -T git@github.comsucceeds -
git logshows 2 commits with meaningful messages - The
.gitignorefile is committed - The repository is visible on GitHub with both commits
Bonus Challenges
- Modify README.md → Add a "Technologies Used" section → Make a third commit
- Create a
src/folder with autils.pyfile → Add and commit - Test
.gitignore: Create avenv/folder → Verifygit statusdoesn't show it - Explore
git show:git show HEAD— what does it display?
Common Mistakes to Avoid
Committed a .env file by accident?
# Remove from tracking (but keep the file locally)
git rm --cached .env
# Add .env to .gitignore
echo ".env" >> .gitignore
# Commit the correction
git add .gitignore
git commit -m "fix: remove .env from tracking"
If you already pushed to GitHub, you need to notify your team and rotate all credentials!
Wrong commit message?
# Correct the LAST commit (before pushing)
git commit --amend -m "New correct message"
# Warning: never amend a commit already pushed to a shared branch
Forgot to add a file to the last commit?
# Add the forgotten file
git add forgotten-file.txt
# Add it to the last commit
git commit --amend --no-edit
# --no-edit keeps the original commit message
Summary
You have successfully:
- Installed and configured Git
- Set up SSH key authentication
- Created a local Git repository
- Made multiple meaningful commits
- Pushed your work to GitHub
You're ready for Module 01 — Git Fundamentals!