There are 2 ways to start a Git repository: create one from scratch (git init), or copy one that already exists on GitHub (git clone). You'll use both depending on the situation.
Option 1 — git init: start from scratch
Use this when you have a new project that has never been in Git before.
mkdir my-first-project
cd my-first-project
git init
This creates a hidden .git/ folder inside the project — this is where all commit history is stored. If this .git/ folder is deleted, the project's entire Git history is lost (but your working files remain).
Check with:
ls -la
You'll see a .git folder among the other files.
Option 2 — git clone: copy an existing repo
Use this when the repo already exists on GitHub (someone else's, or your own created through the website) and you want to work on it locally.
git clone https://github.com/<username>/<repo-name>.git
This command:
- Downloads the entire commit history from GitHub to your machine.
- Automatically creates a new folder matching the repo's name.
- Automatically configures that folder to "know" its remote address (so
git push/git pullimmediately know where to connect).
cd <repo-name>
git status
There are 2 kinds of clone URLs: HTTPS (
https://github.com/...) and SSH (git@github.com:...). For now, use HTTPS — the difference and when to use SSH is covered in full in Part C (Access Security).
git status: the command you'll type the most
After init or clone, get in the habit of immediately running:
git status
This command tells you:
- Which branch you're currently on.
- What files have changed / haven't been committed yet.
- A short hint about what to do next.
You'll type git status hundreds of times while learning Git — it's completely safe to run anytime since it doesn't change anything, it only displays information.
The repo structure you should know
my-first-project/
├── .git/ ← Git history (never edit this by hand!)
├── .gitignore ← list of files intentionally untracked (Module 8)
├── README.md
└── ...your project files
Summary
| Situation | Command |
|---|---|
| New project, not yet in Git | git init |
| Repo already on GitHub, want to work locally | git clone <url> |
| Check repo status (anytime, safe) | git status |
Next up, Part B: the commands you'll use every single day.