Learning Objectives
By the end of this lesson you will be able to:
- Turn any folder on your computer into a Git repository
- Explain what the
.gitfolder is and why you must never delete it - Configure your global name and email so every commit is properly signed
- Verify your setup with
git config --listandgit status
Step 1: Open a Terminal
On macOS it's Terminal (or iTerm). On Windows, install Git and use Git Bash, which gives you the same commands as everyone else. On Linux you already know.
You need exactly one skill to start: moving into a folder.
cd ~/Documents
mkdir qa-notes
cd qa-notes
cd means "change directory". mkdir means "make directory". You are now standing inside an empty folder called qa-notes. Everything in this lesson happens here.
Step 2: git init
One command turns that ordinary folder into a repository:
git init
Git replies with something like:
Initialized empty Git repository in /Users/you/Documents/qa-notes/.git/
That's it. That folder is now a project with a history — an empty one, but a real one.
What Just Happened
Git created a hidden folder called .git inside qa-notes. That folder is the repository: every commit you ever make, every version of every file, the whole history, lives inside it. Your visible files are just the current checkout.
Two consequences worth burning into memory:
- Delete
.gitand you delete the entire history. The files stay; every version of them except the current one is gone forever. - Copy the folder and you copy the history with it. A Git repository is self-contained — no server required.
You can see it with ls -a (the -a shows hidden files):
ls -a
# . .. .git
Never edit anything inside .git by hand. You will never need to.
Step 3: Tell Git Who You Are
Every commit is signed with a name and an email. Git refuses to guess, so set it once, globally, and it applies to every repository on your machine:
git config --global user.name "Olena Kovalenko"
git config --global user.email "olena@example.com"
--global means "for this computer and this user", not "for the whole internet". You can override it inside a single repository later by running the same commands without --global.
Use a Real Email
Use the same email you use for GitHub or GitLab. That's how the platform connects your commits to your account — the profile picture, the contribution graph, the "authored by" link. A typo here means your commits show up as an anonymous stranger, and fixing it retroactively is genuinely annoying.
If you'd rather not publish your personal address, GitHub gives you a free noreply address in your account settings. Use that.
Step 4: Verify
Two commands to confirm everything is right:
git config --list
Look for your user.name and user.email in the output.
git status
You should see something like:
On branch main
No commits yet
nothing to commit (create/copy files and use "git add" to track)
Read that carefully — it's Git's status report, and you'll be reading it constantly from now on. It says: you're on the main branch, nothing has been committed yet, and there are no files to record.
If instead you see fatal: not a git repository, you're in the wrong folder. cd into qa-notes and try again.
Pro Tip: Set
git config --global init.defaultBranch mainonce. Older Git versions still name the first branchmaster, and mixing the two names across repositories is a small, permanent source of confusion.
Key Takeaways
git initconverts a plain folder into a repository by creating a hidden.gitfolder- The
.gitfolder holds the entire history; deleting it destroys every version but the current one git config --global user.nameanduser.emailsign every commit you make on that machine- Use the same email as your GitHub/GitLab account so your commits are attributed to you
git statusis your confirmation that you're in a repository and shows what Git currently sees