World map

 

BM: Baca dalam Bahasa Melayu

World 1: Save Points

Make a repo

You will learn: how to make Git start watching a folder.

The problem

Two files wobble in the diary folder: README.md and index.html. Git is not watching them.

You made a diary website. You want save points. But Git doesn’t even know this folder exists!

Watch

git init prints: Initialized empty Git repository in /home/you/diary/.git/ Terminal output: $ git init Initialized empty Git repository in /home/you/diary/.git/

git init tells Git: “Watch this folder.” Now the folder is a repository. Most people say repo.

Watch

After git init, ls shows README.md and index.html. ls -a also shows a hidden folder called .git. Terminal output: $ git init Initialized empty Git repository in /home/you/diary/.git/ $ ls index.html README.md $ ls -a . .. .git index.html README.md

ls -a lists all files, even hidden ones. See .git? That is the .git folder. Git keeps every save point inside it.

Try it

Make your diary a repo. Then find the hidden folder.

Predict

You delete the .git folder. What happens?

Pick one answer.

Check

Plain ls did not show .git. Why not?

Pick one answer.

You did it!

You can now turn any folder into a Git repo.

Go deeper (optional)

Run git init once per project, inside the project folder. Never in your home folder! Running it twice is safe: Git just says “Reinitialized”. Your first branch: A storyline of commits. Each branch has a name, like main. gets its name from the init.defaultBranch setting. Git 3.0 will use main by default.

Running git init twice. The second time Git says: Reinitialized existing Git repository. Terminal output: $ git init Initialized empty Git repository in /home/you/diary/.git/ $ git init Reinitialized existing Git repository in /home/you/diary/.git/