Chapter 2 · practice
Your First Repository
Edit a File in the Terminal
You have a file to change, and the only tool open in front of you is a
Open a file
In the terminal beside this lesson, run:
nano -w README.md
If README.md does not exist yet, nano creates it when you save. The -w means that nano does not hard-wrap long lines while you are editing. It helps keep the bytes you type separate from the way a narrow terminal displays them.
Type these two lines of text with a blank line between them:
# Garden notes
The first repository will keep this file's history.
The bottom two lines of nano show its most useful controls. A caret means the Ctrl key. For example, ^O means Ctrl-O.
Save, then leave
Save the buffer with:
Press
Ctrl-O.Nano shows
File Name to Write: README.md. PressEnterto accept that name.Press
Ctrl-Xto leave nano.
Back at the
cat README.md
The terminal prints the same two lines. You edited a real file in /workspace; nothing was copied into a separate project editor.
If you get stuck
Nano asks a question at the bottom of the screen instead of accepting normal typing. Ctrl-C cancels the current question and returns you to the buffer.
If you want to abandon the changes, press Ctrl-X, then N when nano asks whether to save. The old file stays as it was. If you saved by mistake, leave nano and reopen the file with nano -w README.md; the next lesson will show how Git gives you another way to inspect and undo changes after the
The safe habit is simple: save deliberately, confirm the filename, then exit. Do not close the browser tab while nano still has changes that you need.
You have finished editing README.md and want the text to reach the file. Which sequence saves it and leaves nano?
The next lesson will put this file under version control. First you will tell Git who is making the