Your First Session
This chapter takes one slow lap of the screen in a repository where you can see everything at once: a few commits, a few branches, and changes in every state a file can be in. The outcome: you can open lazygit, read all five panels without guessing, dismiss the one interruption the first run puts in front of you, and quit cleanly.
The practice repository
The lab's sessions all start from the same place, and yours can too. In this repository's folder:
bash lazygit-lab/mkfixture.sh
cd lazygit-lab/fixture
The script builds a tiny notes project:
a README, three seasonal walk notes, one
small Python helper, three commits on
main, two side branches — and, left
deliberately in the working tree, one
staged new file (shopping.txt), one
modified file (summer-walk.txt) and
one untracked file (winter-walk.txt).
Nothing in it matters; everything in it
is visible. If you would rather use a
repository of your own, choose a small
one with some uncommitted changes; the
chapters only need state to look at.
Opening, and the welcome
lazygit
The screen fills — and, on the very first run, a box appears in the middle of it:
Thanks for using lazygit! Seriously you rock. Three things to share with you:
1) If you want to learn about lazygit's features, watch this vid: …
2) Be sure to read the latest release notes at: …
3) If lazygit has made your life easier, you can say thanks by clicking the donate button …
Press <enter> to get started.
(the whole screen is transcript
lazygit-lab/transcripts/t01-first-screen.txt).
This welcome appears once. Press Enter
to dismiss it — and know, for chapter
17's sake, that while it is up, the keys
you press go to it, not to the panels
behind it. The lab's first exploratory
keystrokes vanished into this box; the
screen looking back at you, unchanged, is
not lazygit ignoring you.
Reading the screen, top to bottom
With the welcome gone, take the panels in their numbered order (chapter 2 has the full anatomy):
[1] Status reads fixture → main:
the repository's folder name, and the
branch you are on. Everything you do in
this session happens to main.
[2] Files shows a folder tree whose
only folder is the root, /, opened,
with three rows:
A shopping.txt
M summer-walk.txt
?? winter-walk.txt
Each row carries a two-letter code in
two columns — the same letters git
status uses. The first column is the
staged state (what the index holds),
the second is the working tree. Read
them as three small stories: A —
shopping.txt is added, staged, ready to
be committed. M — summer-walk.txt is
modified and unstaged; the change is
real but not yet in the index. ?? —
winter-walk.txt is untracked; git has
never been told about it. Chapter 5 works
this panel properly; for now, notice that
the panel answers "what state is my work
in?" in one glance, with no command run.
[3] Local branches lists main with
an asterisk — the branch you are on —
then add-autumn-walk and
fix-heron-count, each with a small time
beside it ("1m", later "6s", "2s"): how
long since that branch last moved.
[4] Commits lists main's three
commits, newest first: a short hash,
author initials (AF, our invented
author Alex Field), a circle on the
history graph, and the subject line.
[5] Stash is empty — "0 of 0" in its bottom border. Chapter 9 fills it.
The main panel on the right is
showing the changes as diffs: first the
unstaged diff of summer-walk.txt (the
added line about a flask of tea, marked
with +), then the staged diff of
shopping.txt below it. And the hint
bar under everything offers the Files
panel's keys: Stage: <space> | Commit: c
| Stash: s | Discard: d | Reset: D |
Keybindings: ?.
Move a little. j and k walk the
selection down and up the file list, and
the main panel follows, showing the
selected file's diff. Nothing has been
changed by looking; you may walk every
panel this way (the digits 1–5 jump
between panels) and leave no trace but
your own understanding.
Check: the state you arrived with is the
state you still have. Quit with q, then
ask git itself:
git status --short
A shopping.txt
M summer-walk.txt
?? winter-walk.txt
The same three stories, in the command line's terser telling.
Opening somewhere else, and nowhere
Two smaller doors exist. lazygit --path
/some/repo opens a repository without
changing into it first, and a positional
word — lazygit log — opens it with the
Commits panel already focused (status,
branch and stash do the same for
theirs).
And if the folder is not a repository at
all, lazygit does not start and does not
crash; before any interface, it asks, in
plain text (transcript
lazygit-lab/transcripts/t11-not-a-repo.txt):
Not in a git repository. Create a new git repository? (y/N):
Answer y and it runs git init for you
and opens on the empty repository. The
lab answered n, and lazygit answered
back — Must open lazygit in a git
repository. No valid recent repositories.
Exiting. — and stopped. That last clause
is the recent-repositories memory of
chapter 2: with somewhere on its list, it
can offer to take you there instead.