Loading lessons...
Get Started with Git
Get Started with Git
The first step in every project is to tell Git: this folder is now a repository.
Create a repository
Open a terminal inside your project folder and run:
git init
Git creates a hidden .git folder here. From now on, Git watches every change you make in this folder.
The three areas of Git
Git tracks files in three areas:
- Working directory where you edit your files.
- Staging area where you prepare files for saving.
- Repository (.git) where your saved versions (commits) live.
The flow is always the same:
Working directory -> git add -> Staging area -> git commit -> Repository
Your first check
After git init, run:
git status
Git tells you which files are untracked, changed, or ready to commit. It is the command you will use the most.
A quick example
git init
git status
Output example:
On branch main
No commits yet
Now you are ready to start tracking files.
TL;DR
git initturns a folder into a Git repository.- Git has three areas: working, staging, and repository.
- Flow: edit,
git add,git commit. git statusshows what Git is tracking.