Hone

Lessons · Git · starting a repository

Starting a repository

git init turns the current folder into a repository by creating a hidden .git folder. The folder is tracked from then on; its files are not until you add them.

Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.

What it is for

Every project starts here, once. Everything Git will ever know about the project lives in that one folder, which is why deleting .git leaves plain files behind.

How to think about it

Go into the project folder, init once, then check git status to see what Git thinks: a fresh repository with no commits and every file untracked.

Worked example

mkdir notes && cd notes
A plain folder.
git init
Creates .git: the repository. Nothing is tracked yet.
git status
On branch main, No commits yet: a repository with an empty history.

Your turn

Make this folder a repository.

git 

The trap

git init in your home folder makes every file you own show as untracked, forever. Init inside the project, never above it.

Practise starting a repository on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.