Typorithm · easy

init, add & commit

git-init-commitgitinitaddcommit
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn init, add & commit

0%

Basics

git init creates a repository (.git directory); git add stages changes into the index; git commit records a snapshot of the staged index with a message. -a stages tracked modifications and -m sets the message inline. Changes flow working tree → index → repository.

git init turns the current folder into a repository by creating a hidden .git directory, where every commit and object is stored. You run it once per project.

git add stages changes into the index (also called the staging area). git add . stages everything; git add <path> stages a single file. The index is the snapshot you are preparing to commit.

git commit records the staged index as a permanent snapshot in the repository, with a message describing it. The -a flag auto-stages modifications to tracked files, and -m sets the message inline. Conceptually, changes move working tree → index → repository.

01

git init creates the .git repository.

02

git add stages changes into the index.

03

git commit -m records a snapshot with a message.

git init
git add .
git commit -m "init"
git add src/app.ts
git commit -am "update"

Read the implementation

Connect each part of the code to the concept before you type.

1. Create a repo

git init creates a new repository by making a hidden .git directory in the current folder.

git init

2. Stage everything

git add . stages every change in the working tree into the index, ready to be committed.

git add .

3. Record a snapshot

git commit records the staged index as a snapshot; -m sets the message inline.

git commit -m "init"

4. Stage one file

git add with a path stages just that file into the index.

git add src/app.ts

5. Stage + commit

-a stages modifications to already-tracked files, and -m sets the message, in one command.

git commit -am "update"

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

init, add & commit: Lesson & Practice · Typorithm | ApplyDjinn