git init & git status
Start tracking a project
Lesson 1 of 20 · 7 min · Module 1: Your first repository
Git remembers every version of your project: what changed, who changed it, and why. Before it can, you turn a folder into a repository.
Start this lesson →Free. No installation: you write and run the code in your browser, and it is checked automatically.
By the end, you’ll be able to…
- Explain what a repository is
- Create one with git init
- Read what git status reports
The idea
git init creates a hidden .git folder: the repository, where Git keeps the history. Your files stay where they are; Git only watches them. git status tells you what Git sees right now: the branch you are on, and which files are new, changed, or ready to be saved.
git init
git status
ls -a
01A repository is a project with a memory
Git stores the history of a folder in a hidden subfolder called .git. Everything else is your working tree: the files you edit as usual. If you deleted .git, the history would be gone, but your files would stay.
02git init creates the memory
Run git init once, in the top folder of the project. Git answers with the full path of the new repository.
git initInitialized empty Git repository in /home/learner/website/.git/03git status is your dashboard
Run git status whenever you are unsure. Right after git init every file is untracked: Git can see it, but it does not save versions of it yet.
git statusOn branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
README.md
about.md
index.html
menu.txt
style.css
nothing added to commit but untracked files present (use "git add" to track)Your turn
~/website, a folder with a small website. Turn it into a repository with git init, ask Git what it sees with git status, then list every file with ls -a to spot the new .git folder.What the checks look for
- ~/website is a Git repository on the main branch
- Checks the status after git init
- Shows the hidden .git folder
Take this with you
git init starts the history; git status shows what Git sees right now.
Go a little further
Run cd ~ and then git status. The fatal message shows how Git reacts outside a repository.