The best way to understand Git is to use it. In this lesson you'll install Git on Windows, macOS, or Linux, tell it who you are, choose a few sensible settings, and create your first repository. You'll also look inside the repository folder so that .git stops being a mystery. Everything here happens on your own computer; no account on any hosting platform is needed.
Before you start
Read What Is Version Control? Understanding Git and Repository Hosting for the concepts. You'll need permission to install software on your computer and a terminal: Terminal on macOS, a terminal emulator on Linux, or Git Bash, PowerShell, or Windows Terminal on Windows.
Installing Git
First check whether Git is already installed:
git --versionIf you see something like git version 2.51.0, you're ready; skip to the configuration section. The latest release on the Git website was 2.56.0 in September 2026. Any reasonably recent 2.x version works for this series, but updating is worthwhile because releases include security fixes.
Windows
Download Git for Windows from the official Git website, or install it with the Windows Package Manager:
winget install --id Git.Git -e --source wingetThe installer asks several questions. The defaults are fine for most people. Two choices are worth understanding:
- Line endings: "Checkout Windows-style, commit Unix-style" (
core.autocrlf=true) is the usual choice on Windows, so files in the repository use LF while your editor sees CRLF. - Credential helper: keep Git Credential Manager, which stores your hosting platform credentials securely in Windows.
Git for Windows includes Git Bash, a terminal with common Unix commands, which matches the examples in this series.
macOS
macOS offers to install the Xcode Command Line Tools, which include Git, the first time you run git. For a more current version, use Homebrew:
brew install gitLinux
Use your distribution's package manager:
# Debian, Ubuntu
sudo apt update && sudo apt install git
# Fedora
sudo dnf install git
# Arch Linux
sudo pacman -S gitDistribution packages can lag behind the latest release. If you need newer features, your distribution may offer a backports repository, or you can build from source.
Configuring Git
Git stores settings at three levels:
- System (
--system): every user on the machine. - Global (
--global): your user account, in~/.gitconfig. - Local (
--local, the default inside a repository): one repository, in.git/config.
More specific levels override less specific ones, so a repository can use a different email from your global one.
Your identity
Every commit records an author name and email. Set them once:
git config --global user.name "Ada Example"
git config --global user.email "ada@example.test"This isn't an account or a login. It's text written into each commit. Hosting platforms use the email to link commits to your profile, so use an address registered with your account there. If you don't want to publish a personal address, most platforms provide a private "no-reply" address you can use instead.
The default branch name
When you create a repository, Git creates a first branch. Current versions still call it master unless you choose otherwise, and print a hint about it:
$ git init recipes
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>Most hosting platforms now create main as the first branch, and Git's own plans for version 3.0 change the default to main too. Set it once to avoid mismatches:
git config --global init.defaultBranch mainA few helpful settings
# Your editor for commit messages (examples: VS Code, nano, vim)
git config --global core.editor "code --wait"
# Make `git pull` refuse to create surprise merge commits (lesson 5 explains)
git config --global pull.ff only
# Colors in the terminal (usually on by default)
git config --global color.ui autoCheck what's set, and where each value comes from:
git config --list --show-originCreating your first repository
Create a project folder and turn it into a repository:
mkdir recipes
cd recipes
git initGit replies Initialized empty Git repository in …/recipes/.git/. Check the state:
$ git status
On branch main
No commits yet
nothing to commit (create/copy files and use "git add" to track)Add a file and make your first commit:
echo "# Recipes" > README.md
git add README.md
git commit -m "Add README"
git log --onelineThe last command shows one line: a short commit ID and your message. You've recorded the first snapshot of your project. Lesson 3 explains each of these commands properly.
Starting from an existing project
If a folder already has files, run git init inside it, then add and commit the files you want tracked. Before your first commit, create a .gitignore so you don't accidentally commit dependencies, build output, or secrets (lesson 3).
Inside the .git folder
The .git folder is Git's database. You'll rarely touch it directly, but knowing what's there removes the mystery:
$ ls .git
HEAD config description hooks index info objects refsHEAD: which branch you're on.config: settings for this repository.objects/: the stored content: file versions, directory listings, and commits.refs/: branch and tag names, each pointing at a commit.index: the staging area.hooks/: optional scripts Git can run at certain moments, such as before a commit.
Don't edit these files by hand; use Git commands. And never delete .git unless you mean to throw away the history.
Authentication comes later
You don't need any credentials to use Git locally. You need them only to push to, or fetch private repositories from, a hosting platform. Lesson 5 covers SSH keys and HTTPS tokens. One rule now: platforms no longer accept your account password for Git over HTTPS; you'll use a token, a credential manager, or SSH keys.
Common mistakes and troubleshooting
- "git: command not found." Git isn't installed, or your terminal was open before installation. Open a new terminal; on Windows, check that Git was added to
PATHduring installation. - "Please tell me who you are." You haven't set
user.nameanduser.email. Set them as shown above. - Commits under the wrong email. Check
git config user.emailinside the repository; a local setting may override your global one. - Running
git initin your home folder. That turns your whole home directory into a repository. Remove the accidental.gitfolder there (rm -rf ~/.git, after checking it's the wrong one) and rungit initinside a project folder instead. - Branch named
masterlocally andmainon the platform. Rename withgit branch -m main, and setinit.defaultBranchfor next time. - Line ending warnings on Windows ("LF will be replaced by CRLF"). These are informational. A
.gitattributesfile with* text=automakes behavior consistent for the whole team.
Practical exercise: set up and inspect
- Install or update Git, and run
git --version. - Set your name, email, default branch, and editor globally; confirm with
git config --list --show-origin. - Create a folder called
notes, rungit init, and rungit status. - Create
README.mdwith one line, add it, commit it, and rungit log. - Run
cat .git/HEADandls .git/refs/heads. What do they tell you about your current branch? - In this repository only, set a different
user.emailwithgit config user.email, make a second commit, and compare the two commits' authors withgit log --format='%h %an <%ae>'.
Key takeaways
- Install Git from your platform's package manager or the official installer, and keep it updated.
- Configure
user.name,user.email, andinit.defaultBranchonce, globally. - Settings live at system, global, and local levels; local wins.
git initcreates a repository;.gitis its database.- No hosting account is needed to use Git.
References
- Pro Git: Installing Git (opens in a new tab)
- Pro Git: First-Time Git Setup (opens in a new tab)
- Git documentation: git config (opens in a new tab)
- Git documentation: git init (opens in a new tab)
- Git for Windows (opens in a new tab)
- Git: planned breaking changes for Git 3.0 (opens in a new tab)
What's next
With Git installed and a repository created, Git Fundamentals: Commits, Staging, History, and .gitignore covers the commands you'll use every day.

