Command line and Git¶
These are the small commands used throughout the course.
Orient yourself¶
Run project commands from the repository root unless documented otherwise.
Inspect files¶
Search quickly:
Run Python¶
uv run uses the project environment. Without uv, activate your virtual
environment first.
Git state¶
Read the diff before staging.
Branch, stage, commit¶
git switch -c lesson/clear-description
git add docs/core/03-arrays.md tests/test_analysis.py
git commit -m "Clarify array-shape contract"
Stage explicit files when unrelated work is present. A commit should capture one coherent change and why it exists.
Restore carefully¶
To discard one unstaged file change:
This is destructive. Inspect git diff -- path/to/file first. Never use
git reset --hard as routine tidying.
Pull and push¶
--ff-only refuses to invent a merge commit when local and remote histories
diverge.
Check an output checksum¶
Linux may use sha256sum instead.
Useful failure clues¶
| Message | First question |
|---|---|
command not found |
is the program installed and on PATH? |
No such file or directory |
what is pwd, and is the path caller-relative? |
ModuleNotFoundError |
which Python interpreter is active? |
Permission denied |
are you executing a file that should be passed to Python? |
| non-zero exit from subprocess | what did stderr say, and which input triggered it? |
Do not prefix arbitrary commands with sudo to silence permissions. Understand
which resource is protected.