Git for Beginners: Install It and Make Your First Commit
Table of Contents
Git is the distributed version control system (VCS). Nearly every developer in the world uses it to manage their code. It has quite a monopoly on VCS. Developers use Git to:
- Keep a history of their code changes
- Revert mistakes made in their code
- Collaborate with other developers
- Make backups of their code
All the content from our Boot.dev courses are available for free here on the blog. This one is the “Setup” and “Repositories” chapters of Learn Git. If you want to try the far more immersive version of the course, do check it out!
What Are Porcelain and Plumbing Commands?
In Git, commands are divided into high-level (“porcelain”) commands and low-level (“plumbing”) commands. The porcelain commands are the ones that you will use most often as a developer. For example:
Some examples of plumbing commands are git apply, git commit-tree, and git hash-object. We’ll focus on the high-level porcelain commands because that’s what you use 99% of the time as a developer, but we’ll dip down into the low-level commands occasionally to really understand how Git works. If you want to go deeper into plumbing, check out Git Internals.
How Do You Install Git?
Git is a command-line tool. It’s a good idea to keep Git up-to-date, since new versions often include fixes for bugs and vulnerabilities, new features, and performance improvements. The official docs site offers helpful installation instructions.
On macOS with Homebrew:
brew update
brew install git
On Ubuntu or WSL:
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
Check your version:
git --version
How Do You Configure Git?
We need to configure Git to contain your information. Whenever code changes, Git tracks who made the change. To ensure you get proper credit (or more likely, blame) for all the code you write, you need to set your name and email.
Git comes with a configuration both at the global and the repo (project) level. Most of the time, you’ll just use the global config:
git config set --global user.name "your_username"
git config set --global user.email "[email protected]"
git config set --global init.defaultBranch main
Your ~/.gitconfig file stores your global Git configuration. You can view it with cat ~/.gitconfig. For more on how config works, see Git Config.
What Is a Git Repository?
The very first step of any project is to create a repository. A Git “repository” (or “repo”) represents a single project. You’ll typically have one repository for each project you work on.
A repo is essentially just a directory that contains a project (other directories and files). The only difference is that it also contains a hidden .git directory. That hidden directory is where Git stores all of its internal tracking and versioning information for the project.
mkdir my-project
cd my-project
git init
You should now have a hidden .git directory. This means you’ve successfully created a new Git repository.
How Do You Check File State With git status?
A file can be in one of several states in a Git repository. Here are a few important ones:
- untracked: Not being tracked by Git
- staged: Marked for inclusion in the next commit
- committed: Saved to the repository’s history
The git status command shows you the current state of your repo. It will tell you which files are untracked, staged, and modified, plus branch/sync status. Get in the habit of running it often.
Why Does Git Have a Staging Area?
Once you’ve created a file, it’s untracked. You need to stage it (add it to the “index”) with the git add command before committing it later.
Without staging, no files are included in the commit — only the files you explicitly git add will be committed.
git add <path-to-file>
Of course, you can just add everything by using the . syntax:
# stages all files at this level and lower
git add .
How Do You Save Changes With git commit?
After staging a file, we can commit it. A commit is a snapshot of the repository at a given point in time. It’s a way to save the state of the repository, and it’s how Git keeps track of changes to the project. A commit comes with a message that describes the changes made in the commit.
git commit -m "add contents page"
If you screw up a commit message, you can change it with the --amend flag:
git commit --amend -m "add contents page"
Half of your workflow as a developer will just be 3 simple commands: git status, git add, and git commit. It’s most of what you need to work effectively as a solo developer. Another 40% of Git is about collaborating and storing your work on a remote server. The last 10% is mostly about fixing mistakes, rolling back changes, and other advanced topics.
How Do You View Commit History With git log?
A Git repo is a (potentially very long) list of commits, where each commit represents the full state of the repository at a given point in time.
The git log command shows a history of the commits in a repository. You can see who made a commit, when the commit was made, and what was changed.
Each commit has a unique identifier called a commit hash. It’s a long string of characters that uniquely identifies the commit.
git --no-pager log -n 10
[!tip] For convenience, you can refer to any commit by using only the first
7characters of its hash.
Frequently Asked Questions
What's the difference between Git and GitHub?
Git is the version control system you run locally on your machine. GitHub is a hosted platform for storing Git repositories, collaborating with other developers, and reviewing code.
What does git init do?
git init creates a new Git repository in your current directory by adding a hidden .git folder. That folder stores all of Git's internal tracking data and commit history for the project.
Why do I need git add before git commit?
git add stages specific changes for the next commit. git commit only saves what is currently staged. Without staging, no files are included in the commit.
What does git status show?
git status shows the current state of your repository. It tells you which files are untracked, staged, and modified, plus branch and sync information.
What is a commit hash?
A commit hash is a unique identifier for a commit. It is a long string of characters, and for convenience you can refer to any commit by using the first 7 characters of its hash.
Related Articles
Git Branching: Create, Switch, and Manage Branches
Mar 31, 2026 by ThePrimeagen - Ex-Netflix engineer, NeoVim ricer, and Git rebaser
A Git branch allows you to keep track of different changes separately. For example, you can create a new branch to experiment with changing a color scheme without affecting your primary branch. If you like the changes, you merge (or rebase) the branch back into main. If you don’t, you delete it.
Git Config: Set Your Name, Email, and Branch Defaults
Mar 31, 2026 by ThePrimeagen - Ex-Netflix engineer, NeoVim ricer, and Git rebaser
Git stores author information so that when you’re making a commit it can track who made the change. Here’s how all that configuration actually works.
Git Internals: How Git Stores Data and History on Disk
Mar 31, 2026 by ThePrimeagen - Ex-Netflix engineer, NeoVim ricer, and Git rebaser
Let’s take a look at some of git’s “plumbing”, that is, the commands that are mostly used for working “under-the-hood” with Git, and that you’ll only use if you’re trying to debug your Git files themselves.
Git Merge: Combine Branches and Understand Fast-Forwards
Mar 31, 2026 by ThePrimeagen - Ex-Netflix engineer, NeoVim ricer, and Git rebaser
“What’s the point of having multiple branches?” you might ask. They’re most often used to safely make changes without affecting your (or your team’s) primary branch. Once you’re happy with your changes, you’ll want to merge them back into main so that they make their way into the final product.