World map

 

BM: Baca dalam Bahasa Melayu

World 1: Save Points

Read git status

You will learn: how to read git status, long and short.

The problem

Five files wobble. index.html and about.html sit in the box. style.css, notes.txt and todo.txt sit in the working folder.

Five files changed. Some are in the box. Some are not. Which ones will your next commit save?

Watch

git status: about.html and index.html are green under Changes to be committed. style.css, notes.txt and todo.txt are red. Terminal output: $ git status On branch main Changes to be committed: (use "git restore --staged <file>..." to unstage) new file: about.html modified: index.html Changes 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: style.css Untracked files: (use "git add <file>..." to include in what will be committed) notes.txt todo.txt

git status sorts your changes into groups. Green lines are in the box. Red lines are not in the box yet.

Try it

Tap every green line: the files in the box.

Tap every line that is in the box.

~/diary $ git status

0 of 2 found

Watch

git status -s prints one short line per file. Green letters on the left, red letters on the right, and ?? for new files. Terminal output: $ git status -s A about.html M index.html M style.css ?? notes.txt ?? todo.txt

git status -s gives the short version. Each line starts with two letters. Left letter: the box. Right letter: your folder.

Try it

Find the untracked files: new files Git isn’t watching yet. They start with ??.

Tap every untracked line.

~/diary $ git status -s

0 of 2 found

Check

You run git add style.css. How does its short line change?

Pick one answer.

You did it!

You can now read git status, long and short.

Go deeper (optional)

Letters you will see: A added, M modified, D deleted, R renamed. MM: part is in the box, part is still in the folder. git status -sb adds your branch: A storyline of commits. Each branch has a name, like main. name on top.

git status -sb: a line saying ## main, then the short status lines. Terminal output: $ git status -sb ## main A about.html M index.html M style.css ?? notes.txt ?? todo.txt