~75 minutes. Initialize a repository, make 3 commits, push to a remote. Verify the history with git log.
Goal: go through the complete Git workflow from init to push with 3 meaningful commits. Understand what the staging area does and why commit messages matter.
Estimated time: 75 minutes
Prerequisites: Week 10 lecture (init, add, commit, push, log); a free GitHub or GitLab account
Setup
If you do not already have a GitHub or GitLab account, create one at https://github.com or https://gitlab.com. Both are free. You will need it for this lab and all future submissions.
Configure Git with your name and email (these appear in your commit history):
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Part A: Initialize a local repo
mkdir -p ~/fnd-101/lab-10-1/my-first-repo
cd ~/fnd-101/lab-10-1/my-first-repo
git init
Verify: git status should show "On branch main" (or "master") with "nothing to commit."
Part B: First commit
Create a README file and commit it:
cat > README.md << 'EOF'
# FND-101 Lab 10.1
My first Git repository.
Created as part of VCA-FND-101: Digital Foundations.
EOF
git add README.md
git status # confirm README.md is staged
git commit -m "Initial commit: add README"
git log # verify the commit appears
Part C: Second commit
Add a second file and commit it:
cat > notes.md << 'EOF'
# Git Notes
git init - creates a .git directory
git add - stages changes
git commit - saves a snapshot
git push - sends commits to remote
git pull - fetches remote commits
git log - shows history
EOF
git add notes.md
git commit -m "Add Git command notes"
Part D: Third commit -- edit an existing file
Modify README.md and commit the change:
echo "" >> README.md
echo "Week 10 notes committed $(date)." >> README.md
git diff README.md # see the unstaged change
git add README.md
git diff --staged # see the staged change
git commit -m "Update README with completion timestamp"
After all three commits:
git log --oneline
You should see 3 commits, newest first.
Part E: Push to a remote
-
Create an empty repository on GitHub or GitLab. Name it
fnd-101-lab-10-1. Do NOT initialize it with a README (you already have one locally). -
Copy the repository URL (HTTPS or SSH).
-
Add the remote and push:
git remote add origin https://github.com/yourusername/fnd-101-lab-10-1.git
# or with SSH:
# git remote add origin git@github.com:yourusername/fnd-101-lab-10-1.git
git push -u origin main
# (use 'master' instead of 'main' if that is your default branch name)
- Open the repository in your browser. Confirm that all 3 commits are visible in the commit history.
Expected output / artifact
In lab-10-1-notes.txt, paste:
- The output of
git log --onelineafter Part D - The remote repository URL
- A screenshot or description of what the repository looks like in the browser (3 commits visible)
git add lab-10-1-notes.txt
git commit -m "lab-10-1: first repo notes"
git push
Common pitfalls
- "fatal: not a git repository": you ran
gitin a directory that is not inside a repo. Rungit initfirst, orcdinto the correct directory. - "reject: non-fast-forward": the remote has commits your local repo does not have. Run
git pullfirst, then push again. - Username/password prompt: GitHub stopped accepting password authentication for HTTPS pushes. Use a Personal Access Token (Settings -> Developer Settings -> Personal Access Tokens) as the password, or switch to SSH.
- "main" vs "master": older Git versions default to "master"; newer ones default to "main". The branch name must match what GitHub/GitLab expects. If they differ,
git branch -m master mainrenames locally.
Stretch (optional)
Create a .gitignore file that ignores *.pyc files and any file named .env. Commit it. Verify that git status does not show a .pyc file you create as "untracked."
Lab 10.1 v0.1.