Install Git and the GitHub CLI, tell Git who you are, make the TaskKit folder a repository, keep node_modules and your own task list out of it with a .gitignore, and save TaskKit's first commit. Learn why a commit saves only what you picked with git add, and how to read git status.
Fundamentals
TypeScript
Git on your computer: commits and a `.gitignore`. Read this lesson at .
Tested with TypeScript 7.x · Node.js LTS
You are writing an essay, and before you rewrite the introduction you
save a copy: essay.docx, then essay-new.docx, then
essay-final.docx, then essay-final-2.docx. A week later you open
the folder and cannot tell which one you sent. TaskKit has the
opposite problem. Since lesson 1.3 you have changed its files hundreds
of times, and each change replaced the version before it. If
tomorrow's change breaks store.ts, yesterday's store.ts is gone,
unless you copied it first, and copying is how the essay folder got
its mess.
Programmers do not copy folders by hand. A tool keeps a version each
time they ask it to, and only then. By the end of this lesson,
the taskkit folder is looked after by that tool, Git: its first
version is saved, node_modules and your own tasks.json are left out
of it, and you can ask Git at any time what has changed since.
A save point for a folder
A version control system keeps the versions instead of replacing
them: you tell it when the folder is in a state worth keeping, and it
saves a copy of every file, so you can see later what changed and
when. The one nearly everyone uses is Git. It works on your computer
alone: nothing leaves it unless you send it somewhere, and sending is
lesson 15.3. Getting an old version back is a lesson of its own,
Git and GitHub: saving and sharing your work in Bonus A; this
lesson makes the save points you would go back to.
A folder Git looks after is a repository; Git keeps everything it
saves in a hidden folder inside it, called .git. Each saved state of
the folder is a commit: a snapshot of the files you chose, with
a short message saying what changed. Think of the save points in a video
game: you decide when to save, each save has a name, and nothing is
lost by saving again. This lesson uses both words for the same thing:
a commit is a snapshot.
Four steps get TaskKit there: install Git and tell it who you are,
make the folder a repository, tell Git which files it must never
save, and pick the rest and commit.
Install Git and the GitHub CLI
All of this is free. You need two programs, and then you tell Git your
name. Git is the first. The second is the GitHub CLI, gh for
short, which lesson 15.3 uses to put TaskKit on GitHub; you install it
now, so that lesson can begin with GitHub itself. CLI stands for
command-line interface: a program you use by typing commands, as you
use TaskKit.
1
Install Git and the GitHub CLI
On a Mac, both come through Homebrew, a free tool that installs
programs from the terminal. Go to brew.sh, copy the
one line under Install Homebrew, paste it into your terminal and
press return. It asks for your Mac's password (nothing
shows while you type it), lists what it will install, and waits for
return: press it again. It then installs Apple's Command
Line Tools, which include Git.
When it ends, it prints Next steps with a few commands. Run them
one by one: they let your terminal find Homebrew. Then install the
GitHub CLI:
Install Git from git-scm.com:
press Click here to download at the top, run the installer, and
keep every option as it is.
Then install the GitHub CLI in your terminal with winget, the
program installer that comes with Windows:
Windows asks whether to let it make changes to your device: press
Yes, as for Git's installer.
Install Git with apt, the program installer that comes with Ubuntu.
sudo in front runs it as the computer's administrator, so it asks
for your password, which does not show as you type:
It lists what it will install and asks Do you want to continue? [Y/n]: press Enter, which answers yes.
For the GitHub CLI, open its Linux install page, and under
Recommended (Official), Debian, run the block under To
install as it is (Ubuntu is built on Debian, so that block is the
one for it). It first tells apt to download gh from GitHub itself:
the gh that Ubuntu ships by itself is an old version that no longer
works with GitHub.
2
Check both in a new terminal
Close your terminal and open a new one, so that it finds the new
programs (lesson 1.2). If you use the terminal inside VS Code (Visual
Studio Code, your editor), quit VS Code completely and start it again,
because its terminals copy the list of programs from VS Code when it
starts. Then ask each program for its version:
Your numbers may be higher.
Your first commit
A commit does not take every file that changed: it takes the ones you
pick, and you pick them with git add. Picking lets one commit hold
one finished change. Say you fixed a typo in README.md and are
halfway through a new command in index.ts: you pick README.md,
commit the fix, and the half-done index.ts waits for a later commit.
Before you pick anything, one file decides what is never picked:
.gitignore, a plain text file in the project's top folder that
lists the files Git should act as if it cannot see. TaskKit's
.gitignore needs two lines:
node_modules/, the nearly 50 MB (megabytes) that npm ci rebuilds on
any computer (lesson 15.1), and tasks.json, your own list, with your trip
to the bank in it.
Here is the trip two files take, from your folder into a snapshot and
on towards GitHub. Pick a file above the figure, README.md or
tasks.json, and press Next step to walk through, or let it
play:
1
Make the folder a repository
In the terminal inside VS Code, in the taskkit folder:
VS Code's panel does not show the .git folder: it hides it on
purpose. It is where every snapshot will live; never edit it by hand.
2
Write the .gitignore
Make a new file, .gitignore, in the taskkit folder. The name
starts with a dot and has nothing before it.
The / after node_modules says it is a folder.
3
See what Git will take
git status answers one question: what does Git see in this folder
right now?
The line in brackets is Git's hint for what to run next; every status
has some, and this lesson needs only the headings and the file names.
Untracked means Git sees the file but has never saved it. Read the
list for what is missing: no node_modules/, no tasks.json. If
either is listed, check the spelling in .gitignore before you go on.
Your list of .ts files may differ a little from this one, depending
on the files you made along the course. On a Mac you may also see
.DS_Store, a small file Finder makes to remember how the folder
looks. It holds nothing of yours; add it as a third line of
.gitignore if you would rather leave it out.
4
Pick the files and commit
First pick the files, and ask Git what it has picked:
and one new file: line for each of the other files. The . after
git add means "this folder", as in code . (lesson 1.2), so Git
picks every file in it that .gitignore does not name. The files
moved from Untracked files to Changes to be committed: picked, and
waiting for the commit. Now make it:
-m is the commit's message: say what the snapshot holds, as you
would name a save in a game. The commit prints its first lines:
The order of those steps matters: the .gitignore comes before the
first git add .. Here is the same commit made in the other order, and
then the one you just made:
Bad — git add . runs before the
.gitignore exists, so every file goes in, your list and
node_modules included.
Good — the .gitignore is written
first, so git add . picks only TaskKit's own files.
Once a file is in a snapshot, writing its name into .gitignore later
changes nothing for it: it stays in that snapshot, and Git goes on
saving it in every new one. Sent to GitHub in lesson 15.3, the Bad
commit would carry your tasks to a page anyone can open, and make
everyone who gets TaskKit download 7,866 files of node_modules.
Predict before you run
Now change a file Git has already saved. Open README.md, add a line
at the end, such as Made by Ana., and save it. Before you ask Git
what it sees, guess:
Predict
In the output of git status, which word comes right before
README.md?
The common mistake: an unpicked change
A commit saves what you picked, so a change that is saved in VS Code
and never picked is not in the next commit. Your README.md is in
that state now. Try to commit it:
Common mistake
Committing a change nobody picked
You write the commit at once, as if saving the file were enough:
Git prints the same status as before and makes no commit:
Git is not broken. A commit saves picked changes, and none was
picked.
no changes added to commit (use "git add" and/or "git commit -a")
The fix
When a change is one you want to keep, pick it first, then commit it:
Your line is only a test, so do not run these two now. Delete the line
from README.md, and the empty line above it if you made one, and
save. Then ask Git once more:
The working tree is Git's name for the files in your folder as they
are now; clean says they match your last commit.
When a commit says no changes added, read the status above it: a
modified: line under Changes not staged for commit is a change
that still waits for git add.
Pass all four tasks to complete the lesson with practice. Reach the end without them and it counts as read only.
Exercises
The page cannot run Git, so the commands are written as console.log
lines, and the questions ask about what Git does.
Recap
Recap · 3 questions
Check yourself
What is a commit?
Check yourself
What does a line in .gitignore do?
Check yourself
git commit says no changes added to commit. What do you
do?
0 of 0 answered.
A cheat sheet to keep
Cheat sheet
Git on your computer: commits and a .gitignore
What things are
Word
What it means
Git
Keeps snapshots of a folder, on your computer
Repository
A folder Git looks after; its history is in .git
Commit
One snapshot of the files you picked, with a message
Branch
A line of snapshots; TaskKit's is main
.gitignore
Files Git acts as if it cannot see, unless already saved
Untracked
A file Git sees but has never saved
Modified
A file in a snapshot that has changed since
Staged
Picked with git add for the next commit
Working tree
Your folder's files as they are now
Git
Write
To
git config --global user.name "Ana"
Say who makes your commits
git init
Make this folder a repository
git status
See what Git sees, changed or new
git add .
Pick every file .gitignore does not name
git add README.md
Pick one file
git commit -m "…"
Save the picked files as a snapshot
Rules
Rule
What it means
.gitignore first
Before the first git add .
Keep out what is rebuilt or private
Where to go next
Your taskkit folder is now a Git repository with its first commit:
node_modules and your own list are left out, and git status tells
you what has changed since. You pick files with git add, and
git commit saves them as a snapshot.
Next is Ship TaskKit: publish it on GitHub with a README and a short
demo recording, the third lesson of Module 15, where you send this
commit to GitHub, share TaskKit with a link, and add a short recording
of TaskKit at work to the README.
Before you move on, make a new file in the taskkit folder called
scratch.txt and run git status to see which heading it lands
under. Then delete the file and run git status once more: it says
nothing to commit, working tree clean, which is how the next lesson
expects to find your folder.
3
Tell Git who you are
Every commit records who made it, so Git needs your name and an email
address. Run these three lines, with your own name and email:
They print nothing when they work. --global saves them once for
every repository on your computer. Git calls a line of snapshots, each
new one made after the last, a branch; TaskKit needs only one. The
third line names the first branch of every new repository main, the
name GitHub uses. Without it, Git on Ubuntu and Windows picks the
older name master and prints a paragraph of advice about it.
Yourfolder
Git
GitHub,lesson15.3
Your folder: README.mdREADME.mdREADME.md
Git: git addgitaddgitadd
Git: git commitgitcommitgitcommit
GitHub, lesson 15.3: to GitHubtoGitHubtoGitHub
Time
A file you wrote, in the taskkit folder.
Picked for the next snapshot.
Kept in a snapshot, with a message.
Lesson 15.3 sends the snapshot to GitHub, where README.md is
the project's front page.
git add takes every file that .gitignore does not name
All 4 steps shown.Step 1 of 4: Your folder: README.mdStep 2 of 4: Git: git addStep 3 of 4: Git: git commitStep 4 of 4: GitHub, lesson 15.3: to GitHub
All 4 steps shown.
Yourfolder
Git
GitHub,lesson15.3
Your folder: tasks.jsontasks.jsontasks.json
Git: skippedskippedskipped
Git: not in itnotinitnotinit
GitHub, lesson 15.3: not sentnotsentnotsent
Time
Your own list, written by TaskKit.
.gitignore names it, so git add leaves it out.
The snapshot is made without it.
It was never in a snapshot, so it stays on your computer only.
git add takes every file that .gitignore does not name
All 4 steps shown.Step 1 of 4: Your folder: tasks.jsonStep 2 of 4: Git: skippedStep 3 of 4: Git: not in itStep 4 of 4: GitHub, lesson 15.3: not sent
All 4 steps shown.
and then one create mode line for each of the other 23 files: each
names a new file in the snapshot. Insertions are lines added.
25a9647 is the start of the commit's id; yours is different, since
every commit gets its own, and your counts depend on the files in your
folder. root-commit marks the first commit, the one with none before
it, and 100644 is how Git records an ordinary file.
On Windows, git add . may first print lines like warning: in the working copy of 'package.json', LF will be replaced by CRLF the next time Git touches it. Windows ends each line of a text file with two
invisible characters, CRLF (carriage return, line feed), where macOS
and Linux use one, LF (line feed), and Git says it will keep them the
Windows way. The warnings are harmless.
node_modules/, tasks.json
Add, then commit
A commit saves only what is picked
Exercise · Read the code
What the commit would save
You changed README.md and index.ts, then ran git add README.md
and git status. What does git commit -m "Update" save if you run
it now? Read the headings and the file names.
text
On branch mainChanges to be committed: (use "git restore --staged <file>..." to unstage) modified: README.mdChanges not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: index.ts
Exercise · Read the code
Ignored too late
Last week you ran git add . before writing a .gitignore, so
tasks.json went into a commit. Today you add tasks.json to
.gitignore and commit that. Is tasks.json still in Git's
snapshots?
.gitignoretext
node_modules/tasks.json
Outputtext
On branch mainNo commits yetUntracked files: (use "git add <file>..." to include in what will be committed) .gitignore README.md ask.ts bar.ts day.ts estimate.ts holidays.test.ts holidays.ts index.ts package-lock.json package.json plan.ts print.test.ts print.ts score.test.ts score.ts store.test.ts store.ts tasks.test.ts tasks.ts time.ts today.test.ts today.ts tsconfig.jsonnothing added to commit but untracked files present (use "git add" to track)
Outputtext
On branch mainNo commits yetChanges to be committed: (use "git rm --cached <file>..." to unstage) new file: .gitignore new file: README.md
The second line of git committext
7890 files changed, 589193 insertions(+)
The second line of git committext
24 files changed, 1212 insertions(+)
Outputtext
On branch mainChanges not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: README.mdno changes added to commit (use "git add" and/or "git commit -a")
Outputtext
On branch mainnothing to commit, working tree clean
bash
brew install gh
bash
sudo apt install git
bash
git --versiongh --version
bash
git init
bash
git status
bash
git add .git status
bash
git commit -m "First version of TaskKit"
bash
git status
bash
git commit -m "Say who made TaskKit"
bash
git add README.mdgit commit -m "Say who made TaskKit"
bash
git status
Outputtext
git version 2.50.1 (Apple Git-155)gh version 2.103.3 (2026-10-26)https://github.com/cli/cli/releases/tag/v2.103.3
git version 2.56.0.windows.4gh version 2.103.3 (2026-10-26)https://github.com/cli/cli/releases/tag/v2.103.3
git version 2.43.0gh version 2.103.3 (2026-10-26)https://github.com/cli/cli/releases/tag/v2.103.3
Outputtext
Initialized empty Git repository in /Users/ana/projects/taskkit/.git/
Initialized empty Git repository in C:/Users/ana/projects/taskkit/.git/
Initialized empty Git repository in /home/ana/projects/taskkit/.git/
Exercise · Fix the error
The first commit, in order
This program prints the steps that save TaskKit's first commit, but in
an order that would fail. Change the order of the lines, without
changing any line itself. git init and write .gitignore may come
in either order. Inside a string written between double quotes, \"
stands for one double quote, so the first line prints
git commit -m "First version of TaskKit".
Loading the editor…
Exercise · Write the code
A .gitignore for a new file
Say you add a feature that makes TaskKit also write backup.json, a
copy of your list made before every save. Print the lines of TaskKit's
.gitignore, one per line, so that neither tasks.json nor its
backup, nor node_modules, is ever picked.
Loading the editor…
powershell
winget install --id GitHub.cli --source winget
Outputtext
[main (root-commit) 25a9647] First version of TaskKit 24 files changed, 1212 insertions(+) create mode 100644 .gitignore