Step 1 of 8

Install Git and check the version

Before anything else, make sure Git is installed on your machine. Most macOS and Linux systems ship with it; Windows users can download it from the official Git website.

Open a terminal and run the version check. If you see a version number, you're ready to go.

bash
# Check that Git is installed
git --version
# Expected output: git version 2.x.x
If the command is not found, install via Homebrew on macOS (brew install git) or apt on Linux (sudo apt install git).
Step 2 of 8

Set your identity

Every commit you make records who you are. Configure your name and email once and Git will stamp every future commit with them.

bash
git config --global user.name "[Your Name]"
git config --global user.email "[[email protected]]"

The --global flag applies the setting to every repository on your machine. Omit it inside a specific repo to set a different identity just for that project.

Step 3 of 8

Create a new repository

A Git repository (or "repo") is just a folder with a hidden .git subfolder that tracks every change. Let's make one.

bash
mkdir my-project
cd my-project
git init

Git will reply with something like "Initialized empty Git repository." You now have an empty repo, ready to track files.

Step 4 of 8

Make your first commit

A commit is a snapshot of your project at a moment in time. To commit, you stage the files you want to include and then save the snapshot with a message.

bash
# Create a file
echo "# My Project" > README.md
# Stage it
git add README.md
# Commit with a message
git commit -m "Initial commit"
A good commit message answers "why was this change made?" — not just "what changed?" — so future-you can understand it.
Step 5 of 8

Track changes with status and diff

As you edit files, Git keeps watch. Two commands tell you what has changed since the last commit.

bash
# What's changed?
git status
 
# Show line-by-line differences
git diff

git status lists which files are modified, staged, or untracked. git diff shows the actual line-by-line changes — green for additions, red for removals.

Step 6 of 8

Branch, switch, merge

Branches let you work on a new idea without disturbing the main line of development. When the idea works, you merge it back in.

bash
# Create a branch and switch to it
git switch -c new-feature
 
# ... make changes and commit them ...
 
# Switch back and merge
git switch main
git merge new-feature
Treat each branch like a draft. If the experiment fails, you can throw it away with git branch -D new-feature and nothing on main is affected.
Step 7 of 8

Push to a remote

A remote is a copy of your repo on a server — usually whichever Git hosting provider your team uses. Pushing uploads your local commits so teammates can see them.

bash
# Connect a remote (once per repo)
git remote add origin "https://[your-git-host]/[your-account]/my-project.git"
 
# Push the main branch
git push -u origin main

The -u flag tells Git to remember the link between your local main and the remote main, so future pushes can just be git push.

Step 8 of 8

You're ready

You now know enough Git to start a project, save your work in commits, branch off for experiments, and share with others. The rest you can learn as you need it.

Three commands you'll use every day: git status to see what's changed, git commit -am "message" to save it, and git push to share it.

When something goes wrong, search for the error message before panicking. Most Git problems have been hit (and solved) thousands of times before.