Fundamentals 7 min read

Master Git in 5 Minutes: Install and Make Your First Commit

This guide walks beginners through installing Git, configuring user identity, initializing a repository, adding files, and completing the first commit, while also explaining core concepts, common pitfalls, and the minimal workflow in a concise five‑minute tutorial.

Code of Duty
Code of Duty
Code of Duty
Master Git in 5 Minutes: Install and Make Your First Commit

Install Git

Verify installation with git --version. On Windows download from https://git-scm.com/ and follow the installer. On macOS run the same command; the system will prompt installation if missing.

Configure Identity

Set the global user name and email that will appear in commit records:

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

Create a Repository

Create a project directory, enter it, and initialize an empty Git repository:

mkdir git-demo
cd git-demo
git init

The command prints Initialized empty Git repository, indicating the folder is now under version control.

Add a File

Create a file, for example hello.txt, with any content:

echo "Hello Git" > hello.txt

Stage the File

Prepare the file for commit: git add hello.txt Git tracks three states:

Working directory : files you are editing.

Staging area : files ready to be committed.

Repository : committed versions.

Make the First Commit

Commit the staged file with a message describing the change: git commit -m "First commit" Successful output includes 1 file changed, confirming the commit.

Minimal Git Workflow

Typical daily commands:

git add .
git commit -m "Your message"

Workflow diagram:

modify file
   ↓
 git add
   ↓
 git commit

View Commit History

Show the log of commits, including author, date, and message:

git log

Common Beginner Pitfalls

1. Commit without staging

Running git commit without a prior git add yields nothing to commit because no changes are staged.

2. Non‑ASCII paths

Use English‑only directory names (e.g., D:/project/git-demo) to avoid path‑related issues.

3. Not knowing what changed

Use git status to list modified, staged, and untracked files.

Summary of Completed Steps

Installed Git.

Configured user name and email.

Initialized a repository.

Added a file.

Made the first commit.

These actions establish the core Git workflow and enable reliable version tracking, safe experimentation, and collaborative development.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

gitcommand lineversion controlrepositorybeginner tutorialfirst commit
Code of Duty
Written by

Code of Duty

"Code of Duty" — Every line of code has its own mission. We avoid shortcuts and quick fixes, focusing on authentic coding reflections and the joys and challenges of technical growth. The journey of learning matters more than any destination. Join us as we humbly forge ahead in the world of code.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.