The brief
Start a new project from scratch. Initialize Git, make commits, push to GitHub. Then clone it on another machine (or another folder) to prove it works.
Step 1: Local setup (10 min)
mkdir my-first-repo
cd my-first-repo
git init
# Initialized empty Git repository in /path/to/my-first-repo/.git/
Configure your identity (one-time):
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
# For new repos, default branch name
git config --global init.defaultBranch main
Step 2: Create some content (5 min)
echo "# My First Repo" > README.md
echo "*.pyc
__pycache__/
.env
.venv/" > .gitignore
mkdir src
echo "def hello():
print('Hello, Git!')" > src/main.py
Step 3: First commit (5 min)
git status
# Untracked files:
# .gitignore
# README.md
# src/
git add .
git status # all green now
git commit -m "Initial commit: README, gitignore, hello script"
git log
# commit abc123... (HEAD -> main)
# Author: Your Name <you@example.com>
# Date: ...
# Initial commit: README, gitignore, hello script
Step 4: Authenticate with GitHub (5 min)
Before pushing you need credentials. Pick ONE:
- HTTPS + PAT (simplest): create a Personal Access Token at github.com → Settings → Developer settings → Personal access tokens → Tokens (classic) → Generate new token (scope
repo). Use it as your password when Git prompts. - SSH key:
ssh-keygen -t ed25519 -C "you@example.com"then add~/.ssh/id_ed25519.pubat github.com → Settings → SSH and GPG keys → New SSH key. Verify withssh -T git@github.com.
Then create the repo:
Step 5: Create GitHub repo (5 min)
Option A: Via web
- Go to github.com → New repository.
- Name: my-first-repo.
- Don't initialize with README (you already have one locally).
- Create.
Option B: Via gh CLI
gh repo create my-first-repo --public --source=. --remote=origin --push
This creates AND pushes. Skip to step 7 (Verify).
Step 6: Add remote and push (5 min)
If you used Option A:
git remote add origin git@github.com:yourname/my-first-repo.git
git remote -v
# origin git@github.com:yourname/my-first-repo.git (fetch)
# origin git@github.com:yourname/my-first-repo.git (push)
git push -u origin main
# -u sets up tracking; future pushes can just be `git push`
Step 7: Verify on GitHub (5 min)
Refresh github.com/yourname/my-first-repo. You should see:
- README.md displayed.
- src/main.py.
- 1 commit.
Step 8: Clone elsewhere (10 min)
In a different directory (or another machine):
cd /tmp
git clone git@github.com:yourname/my-first-repo.git
cd my-first-repo
ls
# .git/ .gitignore README.md src/
cat README.md
# # My First Repo
Your repo is now in two places, synced via GitHub.
Step 9: Make a change and push (5 min)
# Edit README.md (or any file)
echo "
## Description
A learning project for Git." >> README.md
git status
git diff
git add README.md
git commit -m "Add description to README"
git push
Refresh GitHub; the change appears.
Step 10: Pull on the other clone
In the OTHER directory:
cd /tmp/my-first-repo
git pull
cat README.md
# Now shows the updated content
Deliverables
Submission contract: paste your GitHub repo URL into the submission notes. Reviewer checks: ≥2 commits on main, README renders, and a second clone is in sync.
100-pt rubric: repo initialized + identity configured (20) / ≥2 commits with clean messages (20) / remote added + pushed (20) / second clone proves sync (20) / .gitignore excludes .env/.venv (20).
paste your GitHub repo URL into the submission notes. Reviewer checks: ≥2 commits on main, README renders, and a second clone is in sync.
repo initialized + identity configured (20) / ≥2 commits with clean messages (20) / remote added + pushed (20) / second clone proves sync (20) / .gitignore excludes .env/.venv (20).
paste your GitHub repo URL into the submission notes. Reviewer checks: ≥2 commits on main, README renders, and a second clone is in sync.
repo initialized + identity configured (20) / ≥2 commits with clean messages (20) / remote added + pushed (20) / second clone proves sync (20) / .gitignore excludes .env/.venv (20).
- GitHub repo URL.
- Locally:
git log --onelineshows ≥ 2 commits. - README is displayed nicely on GitHub.
- Both clones synced.
What you'll learn
- The basic Git → GitHub workflow.
git init,git add,git commit,git push.git remoteto connect local to GitHub.git clonefor a fresh copy.git pullto sync..gitignoreto skip unwanted files.
Stretch
- Add a
LICENSEfile (MIT, Apache, etc.). - Add a CI workflow (
.github/workflows/ci.yml) that runs a placeholder check. - Add issue and PR templates.
- Add a status badge to the README.