Sikau

Web essentials · Day 15 · about 25 min

Version control with Git

Save points, branches and teamwork.

Undo for your whole project

Ever broken something and wished you could go back? Git records commits — save points of your whole project, with a message saying what changed. Every professional team uses it, usually with GitHub or GitLab.

The everyday workflow

git init                       # start tracking this folder
git status                     # what changed?
git add index.html styles.css  # choose changes for the next commit
git commit -m "Add menu page"  # save point with a message
git log --oneline              # history

git switch -c dark-mode        # new branch for a feature
# …edit, add, commit…
git switch main
git merge dark-mode            # bring the feature in

git push                       # share commits with the remote (GitHub)
git pull                       # get others' commits
  • Commit small, focused changes often.
  • Never commit secrets (passwords, API keys) — list them in .gitignore and keep them in environment variables.
  • A merge conflict means two changes touched the same lines; Git asks you to choose.

The rest of this lesson

  • Branches and pull requestsexplain
  • Habits that save youexplain
  • What does it do?predict
  • A feature, start to finishorder
  • Command → purposematch
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 16 lessons of Web essentials