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.
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
Commit
How does it look in practice? Workflow
Working with Git is based on three main areas: your folder, the staging area, and the archive.
Working Directory
Your folder with files where you write code and create bugs.
Staging Area
The waiting room (git add). Here you choose which changes you want to save.
Repository
Your archive (git commit). Here changes are safely saved forever.
Most common mistakes and pitfalls
Commits are too big
Working on the main branch
Basic commands in the terminal
Before you start, you need to know a few commands that are the foundation of every programmer's work.
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.
| Cecha | Feature | Git |
|---|---|---|
| What is it? | Tool (program) on your computer | Server (cloud) on the internet |
| Offline work | Works fully without internet | Requires a network connection |
| Purpose | Saving version history | Storing 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:
1git commit -m "Add navigati"
1git commit --amend -m "Add navigation"
Pro Tips
Use .gitignore
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
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.
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.
Mathematical Operators: The Foundation of Computing
Learn basic and advanced mathematical operators. Understand how modulo, incrementation works, and why operator precedence matters.