What Git is and why you need it
Theory
Machine translation, not yet reviewed by a native speaker.
Git is a version control system. It remembers the history of changes to a project: who changed what, and when. You can go back to any point in that history.
Without Git, projects look like this: site_final.zip, site_final_2.zip, site_REALLY_final.zip. With Git, it's one folder and a tidy history:
a1b2c3d Add the courses page
9f8e7d6 Fix a login bug
3c4d5e6 First commit
The key ideas:
- a repository (repo) — the project folder plus a hidden
.gitfolder where the whole history is stored; - a commit — a snapshot of all the project's files at a moment in time, with a message saying "what was done". Every commit has a unique ID, its hash (
a1b2c3d…); - a branch — an independent line of development: you can build a new feature without breaking the working version.
A file in Git passes through three places:
working directory ──git add──▶ index (staging area) ──git commit──▶ repository
(you edit here) (what goes into the commit) (history)
The index (also called the staging area) is a waiting area before the commit: you choose yourself which changes go into the next snapshot.
Git ≠ GitHub. Git is a program on your computer. GitHub, GitLab and Bitbucket are websites that store copies of repositories and let teams work together. Your IGD project lives on GitHub, and Kai and Alex push to it with git.
Before you first work on your own computer, git asks you to introduce yourself. This information goes into every commit you make:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
In this course's sandbox everything is already set up. You solve the tasks in real git running right in your browser, and the commit graph is drawn on the right.