Five commands are enough for your daily Git work: init, status, add, commit, log. This lesson walks you through each one on a real folder.
Create a new repo
Create a folder and navigate into it, then:
You will see a message like Initialized empty Git repository in .../.git/. Git just created a hidden .git/ folder at the root. That is where all your history will be stored. Never delete it by hand: you would lose the entire history.
Check the status
At any point, you can ask Git where things stand.
For now, the repo is empty. Create a file to have something to commit:
This time, git status shows README.md listed under "Untracked files". Git sees the file but is not tracking it yet.
Stage the file
To prepare the file for a commit, you put it in the staging area.
Now README.md appears under "Changes to be committed". It is ready to be recorded in history.
Commit
You will see a message like [main (root-commit) a3f5b6c] premier commit.... Your first snapshot is in. The a3f5b6c is the unique identifier for this commit.
View the history
You see your commit, with its full hash, your name, your email, the date, and the message. Press q to exit.
For a more compact format:
The workflow you will repeat
For each change you make after this, the cycle is the same:
- Edit your files.
git statusto see what changed.git add <files>to stage the changes to commit.git commit -m "message"to record them.
And from time to time, git log --oneline to check where you are.
.gitignore: what Git should ignore
You do not want to commit your node_modules/ folder, your .env files, or generated builds. Create a .gitignore file at the root and list the patterns to ignore.
From now on, Git will never show those files in git status again.
What comes next
The next lesson connects you to GitHub to publish your repo and work from multiple machines.
