wleci
AboutProjectsBlogContact
Contact
Back to blog
INF.04GitProgrammingFeatured

Git: What is it and how it works? Version control from scratch

Understand the basics of Git and stop fearing the terminal. Learn about commits, branches, and how to save your code from deletion.

December 24, 20254 min read
Share:

Git: What is it and how it works?

Imagine you are writing an important project and suddenly you break something so badly that you don't know how to go back to a working version. Git is your time machine for code. It allows you to save the state of your files at every stage of work and return to them whenever necessary.

Git

A distributed version control system that tracks changes in text files and facilitates collaboration between multiple people on the same project.

Commit

A snapshot of your project at a given moment. It is a permanently saved change in the repository history.

How does it look in practice? Workflow

Working with Git is based on three main areas: your folder, the staging area, and the archive.

Step 1

Working Directory

Your folder with files where you write code and create bugs.

Step 2

Staging Area

The waiting room (git add). Here you choose which changes you want to save.

Step 3

Repository

Your archive (git commit). Here changes are safely saved forever.

Most common mistakes and pitfalls

Commits are too big

Don't put a whole day's work into one commit. It's better to take small, logical steps. This makes it easier to find bugs in the future.

Working on the main branch

Experimenting directly on the main version of the program is a recipe for disaster. Always create separate branches for new features.

Basic commands in the terminal

Before you start, you need to know a few commands that are the foundation of every programmer's work.

Terminal
$git init
# Creates a new repository in the current folder
$git add index.html
# Adds a file to the staging area
$git commit -m "Add page header"
# Saves changes in the history
$git status
# Checks what is currently happening in your files

Comparison: Git vs GitHub

Many people think they are the same, but that's a mistake. It's like the difference between a spreadsheet and Google Drive.

CechaFeatureGit
What is it?Tool (program) on your computerServer (cloud) on the internet
Offline workWorks fully without internetRequires a network connection
PurposeSaving version historyStoring code and collaboration

Example: How to fix a commit error?

Suppose you made a typo in the description of your last commit. You can fix it without breaking history:

Before
1git commit -m "Add navigati"
After
1git commit --amend -m "Add navigation"

Pro Tips

Use .gitignore

Not all files should go into Git (e.g., passwords, config files, or the node_modules folder). Create a .gitignore file and list the names of things you want Git to ignore.

Quiz: Check your knowledge

Which command moves files from the working directory to the Staging Area?

Branch Visualization (Mermaid)

What's next?

  • Create a GitHub account and upload your first project.
  • Learn what a Pull Request is and how team collaboration works.
  • Practice the git checkout (or git switch) command to jump between versions.
  • Check out graphical tools (GUIs) like GitKraken or SourceTree if you are afraid of the terminal.
  • Solve practical tasks from the INF.04 exam regarding version control systems.

You might also like

INF.04Programming

Relational and Logical Operators: How to Compare Data?

Understand how comparison operators work and how to combine conditions using AND, OR, and NOT. Essential knowledge for control statements.

2 min read
INF.04Programming

Conditional Operator: Short-hand if-else in one line

Learn the ternary operator. Find out how to shorten your code and when to use it instead of classic if-else statements.

2 min read
INF.04Programming

Mathematical Operators: The Foundation of Computing

Learn basic and advanced mathematical operators. Understand how modulo, incrementation works, and why operator precedence matters.

3 min read
Back to blog
wleci.pl

Full-stack Developer

I build modern web applications with passion for clean code and good design.

[email protected]
Poland

Navigation

  • Home
  • About
  • Projects
  • Blog
  • Contact

Services

  • Web applications
  • Websites
  • API & Backend
  • Consulting

Technologies

  • React / Next.js
  • TypeScript
  • Node.js
  • PostgreSQL

Social

© 2026 wleci.pl. All rights reserved.

Privacy policy•Terms of service

Made with in Poland