Web Development — Level 4: Professional Practice — Git, APIs, Testing & Deployment
Get Started Free
Free preview
Git essentials
Lecture notes
Git records snapshots of your project. You can see who changed what and why, return to any earlier version and work on several features at the same time.
git init # start a repository
git config --global user.name "Awa Ndzie"
git status # what changed?
git add index.php # stage a file (git add . for all)
git commit -m "Add course list page"
git log --oneline # history
git diff # unstaged changes
Three areas
- Working directory — your files as you edit them.
- Staging area — the changes selected for the next commit (
git add). - Repository — the saved history (
git commit).
Good commits
- Small and focused: one logical change per commit.
- A message in the imperative that explains why: "Fix rounding of VAT on invoices".
- Never commit secrets: list
.env,vendor/,node_modules/in.gitignore.
Undoing
git restore file.php # discard local changes to a file
git restore --staged file.php # unstage
git revert a1b2c3d # new commit that undoes an old one (safe on shared branches)Want to go further?
22 h · Enroll to access every lesson and earn the certificate.