Build Your First Reproducible Python Data Science Project in GitHub Codespaces¶
Tools: GitHub Codespaces, Python, VS Code, Jupyter, Git, GitHub, integrated terminal
Learning objectives¶
By the end of this tutorial, you should be able to:
create a new GitHub repository for your STA 556 course work;
create and navigate a GitHub Codespace from that repository;
identify the repository root and
/workspaceslocation;navigate a project using the command line;
create and run a Python script;
create and run a Jupyter notebook;
explain the difference between Git and GitHub;
inspect repository status and history;
make commits with meaningful messages;
push your work to GitHub;
explain why the Codespace, repository, code, and documentation are all parts of a reproducible workflow.
Part 0 — Create your STA 556 GitHub repository¶
For this course, you will begin by creating a GitHub repository that will hold your STA 556 work.
If you are not already signed in to GitHub, go to:
https://github.comand sign in.
0.1 Create a new repository¶
From GitHub:
click the + menu in the upper-right corner;
choose New repository;
give the repository a name such as:
STA556If you already have a repository with that name, you could use:
STA556-Fall-2026optionally add a short description such as:
Course work for STA 556: Statistics and Data Science Computing Workflowschoose Private unless your instructor has asked you to make the repository public;
check Add a README file;
for
.gitignore, choose Python if GitHub offers that option;you do not need to add a license for this activity;
click Create repository.
Why add a README?¶
A README gives the repository an initial file and creates the default branch immediately. It also gives you a natural place to document the project as the semester progresses.
0.2 Create a Codespace from your new repository¶
On the page for the repository you just created:
click the green Code button;
choose the Codespaces tab;
click Create codespace on main.
GitHub will create a cloud development environment attached to your new STA 556 repository.
The first Codespace may take a few minutes to start.
When VS Code opens in the browser, open an integrated terminal:
Terminal → New TerminalRun:
pwdYou should see something similar to:
/workspaces/STA556or:
/workspaces/STA556-Fall-2026The exact repository name may differ, but the path should begin with:
/workspaces/Now run:
git statusGit should recognize the repository.
Important¶
When you create a Codespace from a GitHub repository, GitHub automatically places that repository inside the Codespace and configures Git for it.
Do not run git init.
You already have a Git repository.
Part 1 — Set up and check your Week 1 Python environment¶
Because you created a new repository, you will also record the small set of Python packages needed for this activity.
From the repository root, create:
requirements.txtAdd:
numpy
pandas
matplotlib
jupyter
ipykernelSave the file.
Now install the packages listed in it:
python -m pip install -r requirements.txtThis may take a little time the first time.
Now check Python and Git:
python --version
git --versionThen verify the main packages:
python -c "import numpy, pandas, matplotlib; print('Core packages available')"You should see:
Core packages availableWhy create requirements.txt?¶
Rather than remembering package names or installing them randomly, you have written the project’s dependencies into a file that is stored with the repository.
Another person can later see that the project depends on:
numpy
pandas
matplotlib
jupyter
ipykerneland install them with the same command.
Later in the course, we will build on this idea and discuss more complete approaches to reproducible computational environments.
Checkpoint¶
At this point you should know:
the name of your STA 556 GitHub repository;
how you created a Codespace from that repository;
your current working directory;
your Python version;
your Git version;
that your repository is already under version control;
where your project dependencies are recorded;
that the packages needed for this activity are available.
Part 2 — Explore the Codespaces interface¶
Identify the following parts of VS Code:
Explorer → files and directories
Editor → .py, .md, and .ipynb files
Terminal → shell commands
Source Control → Git changesQuestion¶
Why is it useful that these tools all operate on the same repository and computational environment?
Part 3 — Explore the repository structure¶
From the repository root, run:
lsYour new repository will initially contain only a few files.
Create the following project directories:
mkdir -p data notebooks src figuresThen run:
lsYou should now have a simple course-project structure similar to:
README.md
requirements.txt
data/
notebooks/
src/
figures/We will add other project directories later in the semester when we need them.
Important¶
All course paths are written relative to the repository root.
For example:
data/example.csvis preferred to a computer-specific absolute path.
Part 4 — Create your first Python program¶
Inside src/, create:
hello_sta556.pyAdd:
print("Hello from STA 556!")
name = "Your Name"
print(f"Welcome to the course, {name}.")From the repository root, run:
python src/hello_sta556.pyChallenge¶
Modify the program so that it also prints:
the course number;
the semester;
your Python version.
Hint:
import sys
print(sys.version)Part 5 — Create your first notebook¶
Inside notebooks/, create:
week01_exploration.ipynbIf VS Code asks you to choose a kernel, select the Python environment supplied by the Codespace.
Create a Markdown cell:
# STA 556 Week 1 Exploration
This notebook is part of my Week 1 computational workflow.Create a code cell:
import sys
print(sys.version)Then:
x = 10
y = 25
x + yThen:
import math
math.sqrt(144)Reflection¶
What is different about running:
src/hello_sta556.pyand working in:
notebooks/week01_exploration.ipynbWrite 2–3 sentences in a Markdown cell.
Part 6 — Add a small data-science example¶
In the notebook:
scores = [
72,
81,
91,
68,
88,
95,
77,
84
]Calculate:
sum(scores) / len(scores)Then:
import numpy as np
scores = np.array(
scores
)
print(scores.mean())
print(scores.std())Create a plot:
import matplotlib.pyplot as plt
plt.hist(
scores
)
plt.xlabel(
"Score"
)
plt.ylabel(
"Frequency"
)
plt.title(
"Example Score Distribution"
)
plt.show()Save it using a relative path:
plt.hist(
scores
)
plt.savefig(
"../figures/scores.png",
dpi=300,
bbox_inches="tight"
)
plt.show()Part 7 — Understand Git state¶
Run:
git statusGit should show the files you created or modified.
Your repository already has a small Git history beginning with its creation. Inspect it:
git log --oneline -5Question¶
What is the difference between:
a file existing in the Codespaceand:
a file being committed to GitPart 8 — Check .gitignore¶
Look for:
.gitignoreA typical course .gitignore should exclude items such as:
__pycache__/
.ipynb_checkpoints/
.env
.DS_Store
.pytest_cache/Important idea¶
.gitignore tells Git not to track specified files. It does not delete them.
Part 9 — Make your first course commit¶
Run:
git statusStage your Week 1 work:
git add .Check again:
git statusCommit:
git commit -m "Complete Week 1 workflow activity"Inspect the history:
git log --oneline -5Part 10 — Push to GitHub¶
Push your commit:
git pushRefresh the GitHub repository in your browser.
Verify that your new files and commit appear there.
Why this is simpler in Codespaces¶
You do not need to manually create a Git remote for the repository you opened as a Codespace. The repository was already cloned from GitHub and normally has its remote configured.
Check:
git remote -vPart 11 — Make a meaningful second change¶
Open:
src/hello_sta556.pyAdd:
print(
"I am beginning to build reproducible computational workflows."
)Save it.
Run:
git status
git diffThen:
git add src/hello_sta556.py
git commit -m "Add workflow message to Week 1 script"
git pushQuestion¶
What information did git diff provide before the commit?
Part 12 — Write useful repository documentation¶
Open the README.md that you created when you created the repository.
Add a short section describing your Week 1 work, for example:
## Week 1 workflow
This project uses the STA 556 GitHub Codespaces environment.
Week 1 demonstrates:
- repository-relative paths
- Python scripts
- Jupyter notebooks
- Git version control
- GitHub synchronizationCommit and push the change.
Part 13 — Reproducibility check¶
Imagine you delete this Codespace and create a completely fresh Codespace from the same GitHub repository.
The repository contains requirements.txt, so you could first restore the packages with:
python -m pip install -r requirements.txtThen you should be able to:
python src/hello_sta556.pyand open:
notebooks/week01_exploration.ipynbwithout relying on anything installed on your personal laptop.
Reflection¶
Why is this a stronger reproducibility test than saying:
“It runs on my computer”?
Part 14 — Understand persistence¶
Your repository files live under:
/workspaces/Changes there persist when a Codespace is stopped and restarted.
But a file that has never been committed/pushed is not part of the GitHub repository history.
Explain the difference among:
saved in Codespace
committed to Git
pushed to GitHubPart 15 — Stop and reopen your Codespace¶
At the end of your work session:
make sure important work is committed and pushed;
stop the Codespace using GitHub’s Codespaces controls rather than simply relying on closing the browser tab.
Later, reopen the same Codespace and run:
pwd
git statusConfirm your work is still present.
Part 16 — Challenge exercises¶
Complete at least two.
Challenge A — Project metadata¶
Create:
src/project_info.pywith:
course = "STA 556"
semester = "Fall 2026"
language = "Python"Write a function that prints a useful description.
Challenge B — Command-line notes¶
Create:
notebooks/command_line_notes.ipynbDocument five shell commands and explain what each does.
Challenge C — Explore Git history¶
Run:
git log --onelineThen investigate one commit with:
git show <commit-id>Challenge D — Deliberately break something¶
Introduce an error in your Python script, run it, read the traceback, fix the error, then commit the correction.
Challenge E — Portability check¶
Search your code for any path beginning with something like:
C:\\Users\\...
/Users/...Replace it with a repository-relative path.
Part 17 — Final reflection¶
Answer in your README or notebook.
1. Codespaces¶
What is a GitHub Codespace, and why does STA 556 use one?
2. Git vs. GitHub¶
Explain the difference between Git and GitHub.
3. Repository root¶
Why do course instructions assume commands are run from the repository root?
4. Commit vs. push¶
What is the difference between committing and pushing?
5. Notebook vs. script¶
When would you choose a Jupyter notebook? When would you choose a Python script?
6. Reproducibility¶
Why are relative paths and a repository-defined environment useful?
Completion checklist¶
Created a new STA 556 GitHub repository
Created a Codespace from that repository
Located the repository under
/workspacesCreated and used
requirements.txtUsed the integrated terminal
Verified Python and Git
Explored the VS Code interface
Created/run a Python script
Created/run a Jupyter notebook
Used repository-relative paths
Inspected
git statusInspected Git history
Reviewed
.gitignoreMade a meaningful commit
Pushed to GitHub
Used
git diffUpdated repository documentation
Completed a reproducibility check
Explained saved vs. committed vs. pushed
Stopped/reopened the Codespace
What you should now understand¶
Create your STA 556 GitHub repository
↓
Create a Codespace from that repository
↓
VS Code + Linux shell + Python
↓
notebooks / src / data / tests
↓
Git commits
↓
git push
↓
reproducible project history