First steps · lesson 2 of 8
Commands and ideas in this lesson
Apwdwhere am I?
Blswhat's here?
Ccdgo into a folder
Dmkdirmake a folder

Just enough terminal

Last updated

Git is used by typing commands in a terminal. You need about six of them, and this lesson teaches all six: where am I, what's here, go there, make a folder, and two keys that save a lot of typing.

By the end of this lesson you can

  • Say which folder you're in, and list what's in it
  • Move between folders with cd, including .. and ~
  • Make a folder with mkdir
  • Read an error message and fix the command

What a terminal is

A terminal is a window where you type commands instead of clicking. You type a line, press Enter, and the computer runs it and prints what happened. The text before where you type, often ending in $ or >, is the prompt. Many prompts show the folder you're in.

Git has buttons in many editors and apps, but every one of them runs the same commands underneath, and Git's own documentation, error messages and help all use the commands. Learn them once and every Git tool makes sense.

You'll open a real terminal on your own computer in lesson 1.3. Until then, the terminal in this page is enough. It understands the commands in this lesson and Git's own.

Where am I, and what's here?

A terminal is always "in" one folder, called the current folder (or working directory). Two commands tell you about it:

  • pwd (print working directory) prints the full name of the folder you're in.
  • ls (list) prints what's in it. Folders are shown with a / at the end in this sandbox.

Your home folder is /home/ana here. On your own computer it's something like /Users/ana on a Mac or C:\Users\Ana on Windows.

Try both. The tree on the right shows where you are.

Terminal
  1. Type pwd to see where you are
  2. Type ls to see what’s here
You are in your home folder, /home/ana. Git is installed and set up.

Your folders

  • /home/ana◀ you are here
    • kusina/
      • adobo.md
      • sinigang.md
    • photos/
      • lola-birthday.jpg
    • notes.txt

Moving around: paths, .. and ~

cd (change directory) moves you into a folder: cd kusina. A few short names help:

You typeIt means
cd kusinago into the folder kusina, inside the one you're in
cd ..go up one level, to the folder this one is in
cd ~ or just cdgo to your home folder
cd ~/kusinago to kusina in your home folder, from anywhere

A folder's name with the folders above it, like /home/ana/kusina, is its path. mkdir (make directory) makes a new folder: mkdir notebook.

Go into kusina and look around, come back up, then make a new folder and go into it.

Terminal
  1. Go into kusina and list what’s in it
  2. Go back up to your home folder with cd ..
  3. Make a folder called notebook and go into it
You are in your home folder, /home/ana. Git is installed and set up.

Your folders

  • /home/ana◀ you are here
    • kusina/
      • adobo.md
      • sinigang.md
    • photos/
      • lola-birthday.jpg
    • notes.txt

The sandbox keeps you at the top of each project folder, which is all this course needs. Your own computer lets you go anywhere.

Two keys that save typing

  • Tab completes names. Type cd ku and press Tab, and the terminal fills in kusina/. If more than one name fits, it shows them all. Completion also stops typos, because it only fills in names that exist.
  • The up arrow brings back earlier commands. Press it to get your last command back, again to go further back, then edit it and press Enter.

Both work in this sandbox and in every terminal in this course. Try them in the terminal in step 3.

Spot the trap: the wrong folder

Commands act on the folder you're in. Running one in the wrong folder is the most common terminal mistake, and with Git it can be a big one, as you'll see in lesson 1.4.

Ana's terminal
pwd
/home/ana
cat adobo.md
cat: adobo.md: No such file or directory
Spot the trapAna

Ana opens a terminal and types cat adobo.md to show the adobo recipe. The terminal says No such file or directory.

What happens if…

Errors in a terminal are usually short and exact. Read the last line first: it names the command that failed (cat), the thing it couldn't find (adobo.md), and why.

Check what you learned

You’re in /home/ana/kusina. Where does cd .. take you?
Which command tells you which folder the terminal is in?
A command says No such file or directory, but you’re sure the file exists. What do you check first?

Sources

Every command on this page behaves as these pages describe, and the sandbox prints what Git 2.55 prints. Hosting features (pull requests, protected branches) come from the host’s own documentation.

All sources for Simple Git