Skip to content
CodeItRaw
Git Basics

Lesson 1/4

Git keeps the history of a folder. Each commit is a photograph of the files as they were at that moment, and carries a message: what changed, and why. You can go back to any photograph and compare any two. git init turns a folder into a repository.

git init
git status
git add notes.md
git commit -m "Add meeting notes"
git log --oneline
A commit is two steps. git add puts a change on the stage: "this goes into the next photograph". git commit photographs what is on the stage. git status tells you what has changed and what is staged; git log shows the history.

The stage exists so that you can choose. If you changed two files and only one is ready, you add only that one; the other waits for the next commit. A good commit tells of one piece of work. Every commit has a short id (like a1b2c3d); it is by that id that you point at it in the history.

Tasks

Tasks open in order. Solve them all and the next lesson opens.

This lesson's tasks open when the lessons before it are finished. You can read the explanation now.

  1. 01

    First commit

    Git task

  2. 02

    Stage selectively

    Git task

  3. 03

    Read the history

    Git task

If you would rather not wait for the order, every problem is open without locks: Problem list