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 notesA plain folder.
git initCreates .git: the repository. Nothing is tracked yet.
git statusOn branch main, No commits yet: a repository with an empty history.
Your turn
Make this folder a repository.
git
Try it in a real repository
The trap
git init in your home folder makes every file you own show as untracked, forever. Init inside the project, never above it.