
What you need
- Computer and internet: a laptop or desktop and a stable connection
- System: Windows 10 or 11, macOS or Linux
- Tools: Git (search for "Git official download") and a code editor such as Visual Studio Code (search for "VS Code official download")
Download only from each tool's official site and check the address before installing.
What you will learn
You will install and set up Git, turn a folder into a repository, and save your first commit. You will also learn the one habit that protects you from the most common, most expensive beginner mistake: committing a password.
You need a computer and about 30 minutes. No coding knowledge is needed. Every command has a Copy button: copy it, paste it into your terminal, press Enter.

Git feels strange for the first week and natural forever after. Everyone you admire went through that first week too.
Why Git exists
Imagine writing an essay and saving it as essay.docx, then essay-final.docx, then essay-final-v2.docx, then essay-final-REALLY-final.docx. You lose track of what changed, when, and why. Now imagine three people editing it at once.
Git solves this. It keeps a complete history of your project as a series of snapshots. Each snapshot (a commit) records exactly what every file looked like, who saved it, when, and a short message saying why. You can look back at any snapshot, compare two of them, or undo a change, at any time.
Almost every software team in the world uses Git. Learning it is not optional for a developer; it is like learning to save your work.
Three words to know first
| Word | Meaning | Everyday picture |
|---|---|---|
| Repository | A folder Git is watching, with its full history | A photo album |
| Commit | One saved snapshot, with a message | One photo with a caption |
| Staging area | The changes you have picked for the next commit | Photos you have chosen to print next |
Step 1: Install Git
Check if Git is already installed. Open a terminal and run:
git --version
If you see something like git version 2.47.0, you are ready; skip to Step 2. Any version from 2.28 up works with this lesson. If you see "command not found" or "not recognised", install it:
- Windows: download the installer from the official site, git-scm.com, and accept the default options. It also installs Git Bash, a terminal that understands every command in these lessons. On Windows, use Git Bash (search for it in the Start menu) for this lesson and the ones after it.
- macOS: run
git --versiononce; macOS offers to install the developer tools that include Git. Click Install. - Ubuntu or Debian Linux: run
sudo apt updatethensudo apt install git.
Close the terminal, open a new one, and run git --version again to confirm.

Only download tools from their official website. Typing "download git" into a search engine sometimes shows lookalike sites first.
Step 2: Tell Git who you are (once per computer)
Every commit records an author. Set your name and email once:
git config --global user.name "Your Name" git config --global user.email "[email protected]"
Use the same email you use (or will use) on GitHub, so your commits link to your profile.
Now one more setting. For historical reasons, Git currently calls the first branch master, while GitHub and most teams use main. The Git project has announced that Git 3.0 will switch the default to main; until then, set it yourself:
git config --global init.defaultBranch main
Check your settings any time with:
git config --global --list
Step 3: Create a project and turn it into a repository
Make a folder for this course and move into it:
mkdir -p ~/ewoi-learning/first-app cd ~/ewoi-learning/first-app
mkdir -p makes the folder (and any missing parent folders). cd moves you into it. The ~ means your home folder.
Now tell Git to start watching this folder:
git init
You will see Initialized empty Git repository in .../first-app/.git/. Git created a hidden folder named .git. That folder is the whole history. You never need to open it, and you should never delete it. Stay in ~/ewoi-learning/first-app for the rest of this lesson: every command below runs there.
Step 4: Keep secrets out, before anything else
A secret is any password, API key or token that gives access to something. Real projects have them: a database password, a payment provider key, an email service key.
Here is the trap: once a secret is committed and pushed to GitHub, deleting it in a later commit does not remove it. The history keeps every old version, and automated bots scan public repositories for leaked keys within minutes. If it happens, you must change (rotate) the secret immediately.
The protection is a file named .gitignore. It lists files and folders Git must never track. Professionals create it before the first commit, so nothing secret can slip into history even once. Create it now:
printf ".env\nnode_modules/\nvendor/\n" > .gitignore cat .gitignore
printf writes the three lines into the file (\n means "new line"), > sends them into a file instead of the screen, and cat shows the file so you can check it. You should see:
.env node_modules/ vendor/
| Line | What it ignores | Why |
|---|---|---|
.env |
The file where projects keep their real secrets | Secrets never belong in history |
node_modules/ |
Downloaded JavaScript packages | Huge, and anyone can re-download them |
vendor/ |
Downloaded PHP packages | Same reason |
Professional projects also commit a file named .env.example that lists the setting names with fake placeholder values, so a teammate knows what to fill in without ever seeing your real secrets.
Step 5: Check the status
Now ask Git what it sees:
git status
You will see:
On branch main No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) .gitignore nothing added to commit but untracked files present (use "git add" to track)
.gitignore is listed under Untracked files, in red. Untracked means: "this file exists, but I am not keeping history for it yet".

Run git status whenever you feel lost. It never changes anything; it only tells you where you are.
Step 6: Stage the file
Choose the file for your next snapshot:
git add .gitignore git status
The file moves to Changes to be committed, in green, shown as new file: .gitignore. It is now in the staging area.
Why not save straight away? Because the staging area lets you choose. If you changed five files but only three belong together, you stage those three, commit them with a clear message, then commit the other two separately. Small, focused commits are much easier to understand and undo later.
Step 7: Commit
Save the snapshot with a message:
git commit -m "Ignore secrets and downloaded packages"
-m means "message", and the text in quotes is that message. Git replies with a short summary:
[main (root-commit) 892828d] Ignore secrets and downloaded packages 1 file changed, 3 insertions(+) create mode 100644 .gitignore
892828d is a short ID (yours will differ). That ID is your commit's unique name. "root-commit" means it is the very first commit in this repository, and 3 insertions(+) counts the three lines you added.

Make .gitignore your first commit in every new project. It costs ten seconds and can save you a very bad day.
Step 8: Add a README with the same loop
A README is the front page of a project: what it is and how to use it. Create one, then stage and commit it exactly as before:
echo "# My first app" > README.md git add README.md git commit -m "Add a README"
echo prints text, and > sends it into a file. This time the summary has no "root-commit", because history already exists:
[main 69b0b34] Add a README 1 file changed, 1 insertion(+) create mode 100644 README.md
See your history:
git log --oneline
One line per commit, newest first:
69b0b34 Add a README 892828d Ignore secrets and downloaded packages
Congratulations: you have a project with history.
Writing good commit messages
Your future self (and your teammates) will read these messages when something breaks. A simple rule: the message should complete the sentence "If applied, this commit will..."
| Weak | Strong |
|---|---|
| stuff | Add contact form |
| fix | Fix price rounding on the checkout page |
| changes | Update README with setup steps |
| asdf | Remove unused images |
Keep the first line under about 50 characters, start with a verb, and describe what changed. If you need to explain why, add more lines in a longer message (run git commit without -m and an editor opens).
Ask your AI assistant
Here is what I changed in my project: [describe the change in plain words]. Suggest three short commit messages that complete the sentence "If applied, this commit will...", and tell me which is best and why.
What just happened (the full picture)
Every change you make follows the same loop:
- Edit files in your folder (your working directory).
- Stage the changes you want with
git add. - Commit them with
git commit -m "message". - Check where you are any time with
git status, and look back withgit log --oneline.
Common beginner mistakes
| Problem | What it means | Fix |
|---|---|---|
fatal: not a git repository |
You are in a folder Git is not watching | cd into your project folder, or run git init if it is a new project |
Please tell me who you are |
Step 2 was skipped | Run the two git config --global commands |
nothing to commit, working tree clean |
Nothing changed since your last commit | Not an error. Change a file first |
You ran git add . and staged too much |
. means "everything here" |
git restore --staged filename unstages one file. Before your very first commit, use git rm --cached filename instead (it keeps the file on disk) |
Ask your AI assistant
I am learning Git. I ran this command: [paste the command] and got this message: [paste the full message]. Explain in simple words what it means and what I should run next. Do not assume I know Git terms.
Recap
- Git keeps a history of your project as snapshots called commits.
git initstarts a repository; the history lives in the hidden.gitfolder.- The loop is: edit,
git add,git commit -m "...". git statustells you where you are;git log --onelineshows history.- A
.gitignorekeeps secrets and downloaded packages out of history. Make it your first commit, before any other file.
Your practice task
In ~/ewoi-learning/first-app, make three more commits. Try each one yourself first, then compare with the commands:
- Add a second line to
README.mddescribing what the app will do, and commit it with the messageDescribe the app in the README. Use a double>>, which adds to the end of the file instead of replacing it. - Create
notes.txtwith one thing you learned and commit it with the messageAdd learning notes. - Add a second line to
notes.txtand commit it with the messageAdd a note about git status.
echo "A small app to learn Git." >> README.md git add README.md git commit -m "Describe the app in the README" echo "Git saves snapshots called commits." > notes.txt git add notes.txt git commit -m "Add learning notes" echo "git status shows where I am." >> notes.txt git add notes.txt git commit -m "Add a note about git status"
Then run git log --oneline. You should see five commits, newest first (your IDs will differ):
25c155f Add a note about git status dde06fc Add learning notes c73994e Describe the app in the README 69b0b34 Add a README 892828d Ignore secrets and downloaded packages
Run git status one last time. nothing to commit, working tree clean means everything is saved. Your project now looks like this (.git is hidden):
first-app/ ├── .gitignore ├── README.md └── notes.txt
The next lesson, Branches without fear, continues in this same folder.
Ask your AI assistant
I am a Git beginner. Here is my git log --oneline: [paste it]. Check whether my commit messages follow the "If applied, this commit will..." rule, and suggest a better wording for any that do not.
Check your understanding

Every lesson stays free. Tap the thumbs up so we know what works, or say thanks with a soda or a coffee: it pays for hosting and new lessons.


