The Terminal, Gently
Git is a program you talk to by typing, so before Git you need the place where typing happens. If you have never opened a terminal, this is the page that makes the rest of the book possible.
A terminal is a window where you type the name of a program and press Enter, and the program runs. That is the entire idea. Films have given it a reputation it does not deserve: nothing here is dangerous, and nothing you type in this book can damage anything outside the folder you are standing in.
Think of it as a file manager where you type the destination instead of clicking it. Same folders, same files, different steering wheel — and once you can steer, you can drive anything.
Opening it
On macOS, open the Terminal app (Spotlight, then type "terminal"). On Windows, the Git installer in the next topic brings Git Bash, which is the one to use for this book; Windows Terminal and PowerShell also work. On Linux you already know where yours is.
What appears is a mostly empty window with a line of text and a blinking cursor. That line is the prompt: the terminal saying it is ready and waiting.
Where am I?
Here is the fact that makes everything else make sense: a terminal is always sitting inside one folder. Commands act on that folder unless you say otherwise. When Chapter 2 tells Git to start tracking a project, what it really does is act on wherever you happen to be standing.
The command that tells you where that is:
pwd
It answers with a path, something like /Users/you/projects/sandpiper. The name is short for "print working directory", and you will type it more often than you expect — usually about four seconds after wondering why a command did not do what you meant.
Looking and moving
Three more commands and you can navigate anywhere. ls lists what is in the current folder. cd followed by a folder name steps into it. cd .. — with two dots — steps back out to the folder above.
ls cd sandpiper ls
One habit worth building immediately: press the Tab key after typing the first few letters of a name and the terminal completes it for you. It is the difference between comfort and a long afternoon of typos, and it also confirms the thing you are typing actually exists.
The shape of a command
Every command in this book has the shape in that diagram: the program, then which job you want it to do, then options that adjust the job, then whatever the job needs. git commit -m "Fix the meeting time" is four parts, not one incantation, and once you see the parts you can read commands you have never met.
Two small rules save a lot of pain. Anything containing a space goes inside quotes, or the terminal treats each word as a separate item. And the terminal is fussy about spelling in a way that people are not: Sandpiper and sandpiper may well be different names.
Reading an error instead of fearing it
Errors are how these programs talk. Here is one on purpose:
cd sandpper cd: no such file or directory: sandpper
Read it as a sentence. The command was cd. The problem is "no such file or directory". The thing it could not find is sandpper, which is missing an i. Nothing is broken, nothing was changed, and the message contains the whole diagnosis.
The exact wording depends on which shell you are using, and the same three parts are always in it. On Windows, Git Bash puts them in a different order:
cd sandpper bash: cd: sandpper: No such file or directory
Command, then the name it could not find, then the problem. Different order, same three pieces of information. Getting used to picking those pieces out of any error message is worth more than memorising one shell's phrasing.
That is the pattern for the rest of the book. Error messages from Git are longer, but they are built the same way, and the last line is almost always the useful one. Git very often prints the exact command it thinks you want next.
Silence means it worked
One last surprise. Most of these commands say nothing at all when they succeed. Run cd sandpiper correctly and the terminal simply gives you a fresh prompt. That is not a failure and it is not the terminal ignoring you — silence is the good outcome, and text is usually either an answer or a problem.
- "The terminal is dangerous — I could delete everything by accident." Nothing in this book deletes anything outside the folder you are in, and the few commands that can destroy work are flagged where they appear. A command that does not exist simply does nothing.
- "I have to memorize all the commands." Four commands cover this page and six carry the whole book. Professionals look up the rest forever; that is what the documentation is for.
- "Nothing happened, so it failed." Most of these commands are silent on success. If you want confirmation, run
pwdorlsand look. - "The terminal is a different computer from my file manager." It is the same disk, the same folders, the same files. Create a file in the terminal and it appears on your desktop immediately.
- Every Git command in the next ten chapters gets typed here. Readers who skip this page spend the rest of the book unsure whether a problem is Git or the terminal, which makes both harder.
- "The terminal is always standing in one folder" is what makes
git initcomprehensible in the next chapter — Git acts on where you are, not on a project you selected from a menu. - Reading an error as a sentence rather than a wall of red is the single habit that separates a five-minute problem from an hour of guessing.
Knowledge Check
You run a command and the terminal prints nothing before showing a fresh prompt. What happened?
- It almost certainly succeeded, since most of these commands stay silent when they work
- The command failed silently and will need to be run a second time
- The terminal is still working and will print the result when it finishes
- The command was not recognized, so the terminal skipped it without comment
In git commit -m "Fix the meeting time", what is -m?
- An option that adjusts how the job is done, with its value following straight after
- The name of the file that the commit will be recorded into
- A second subcommand, telling Git to run "commit" and then "m"
- A required marker that has to appear before any text containing spaces
Why does the book insist that a terminal is always sitting inside one folder?
- Because commands act on wherever you are standing, including the one that starts a repository
- Because the terminal can only ever open files that live in one specific folder
- Because Git refuses to run unless the terminal is inside your home directory
- Because moving between folders requires closing the terminal and opening a new one
The terminal answers cd: no such file or directory: sandpper. What is the useful part?
- The name it could not find, which is misspelled and points straight at the fix
- The word "directory", which means the folder has been damaged and needs recreating
- The colons, which indicate how serious the error is and whether work was lost
- Nothing useful — the message is generic and the real cause is somewhere else
You got correct