CHAPTER 1 · 1 lesson · 13 exercises
Basics of Commits
Stage changes and create commits. Navigate between the working tree, staging area, and local repository.
"The earlier version was better, and I've already saved over it."
Git was built for that one sentence.
You could keep adding files — report_final.txt, report_final2.txt, report_really_final.txt — but you'll soon lose track of which was which. Git turns "give it a name and save it" into a proper tool. You can go back to any commit you like, and when, what and why it changed is kept alongside it in commit messages.
There are only three commands in this chapter:
git init… initialize this directory as a Git repositorygit add… add changes you want to commit to the staging area (index)git commit… record staged changes as a permanent commit
The concept that takes the longest to click is why there's a staging area at all. You don't always want all edited files in the same commit. The staging area lets you selectively register changes, committing only what is ready.
The Git in this course runs entirely inside your browser. Nothing you write leaves your device. Your history is drawn as a commit graph, so you can watch the shape change as you type.
Lessons in this chapter
Commits
- 01Your first commitInitialize a repository, add changes to the staging area, and record your changes with git init, git add, and git commit.Go to the exercises