toolrota

What is Git: version control, commits, branches and merging for beginners

If you are tired of saving files as 'final_final2', Git is for you. We explain the core concepts and commands in plain language.

Serkan Akyürek··4 min read
What is Git: version control, commits, branches and merging for beginners – SaaS & Cloud

If you've ever saved a document as "report_final," "report_final_v2" and "report_final_v2_real," you've met the version problem. Git is a version control system that records changes to files and makes it easy to go back in time and work together. It is a core tool for developers and is also useful for writers and designers. This guide covers the core concepts and commands.

What is Git and why use it?

Git records each important change to the files in a folder as a snapshot (commit). That way if you make a mistake you can go back, see who changed what and why, and work with several people on one project without clashes. It is the foundation of the open source world (see our open source guide).

Are Git and GitHub the same?

ConceptMeaning
GitThe version control tool that runs on your computer
GitHub / GitLabServices that host Git repositories online and offer collaboration (see our GitHub guide)

You can use Git offline too; remote services are added for backup and sharing.

Core concepts

ConceptMeaning
RepositoryThe project's files and all their history
CommitA snapshot of changes saved with a message
BranchAn independent line of development apart from the main line
MergeCombining one branch into another
CloneCopying a remote repository to your computer
Push / PullSending changes to / getting them from the remote repository
StagingThe area where you pick the changes that go into a commit
The daily Git workflow
  1. 1

    You make changes to files

  2. 2

    You choose which changes to record (add)

  3. 3

    You create a commit with a descriptive message

  4. 4

    You send the changes to the remote repository (push)

  5. 5

    You pull others' changes (pull)

Basic commands

CommandFunction
git initStarts a new repository
git clone urlCopies an existing repository
git statusShows the state
git add fileStages a change
git commit -m "message"Creates a commit
git logLists history
git branch and git switchLists and switches branches
git merge branchMerges a branch
git pull / git pushGets from / sends to remote

Using branches

Open a separate branch for a new feature or fix; work without breaking the main branch. When done, merge the branch into main. This isolates mistakes and organises teamwork.

Merge conflicts

If two people change the same line differently Git can't know which to choose and reports a conflict. You resolve it by editing the conflicting section by hand and saving. Small, frequent commits reduce conflicts.

Good commit habits

  1. Make small, focused commits.
  2. Write a descriptive message: what changed and why?
  3. Don't push broken code to the main branch.
  4. Push often; it doubles as a backup.
  5. Don't put secrets in the repository: passwords, API keys and .env files (see our API key security guide).
  6. Use .gitignore to leave out unneeded and sensitive files.

If you did something wrong

  • If you haven't committed yet: you can undo changes.
  • If you committed: creating a new "revert" commit is the safe path.
  • If you accidentally pushed a secret: revoke and replace the key at once; deleting it from history alone isn't enough.

Who else uses Git?

Writers, designers and document teams can also use Git to track versions of text-based files. It is limited for binary files (large images).

Common mistakes

  1. Making huge, mixed commits.
  2. Writing meaningless messages ("fix").
  3. Pushing secrets.
  4. Working directly on the main branch.
  5. Trying to push without pulling and hitting conflicts.

Frequently asked questions

Is Git hard to learn? The basic commands are learned in a few hours; deeper features come with time.

Is there a graphical interface? Yes, there are many visual tools and editor extensions.

Does it replace backup? Not fully; with a remote repository it helps but also take a separate backup (see our 3-2-1 backup guide).

Summary

Git is the version control system that keeps file history and eases collaboration. Learn repository, commit, branch and merge; make small, described commits and keep secrets out of the repository.

Share
Published:
Author
Serkan Akyürek

Serkan Akyürek is the founder and author of toolrota; he writes step-by-step guides on Excel, AI, the cloud, personal finance and digital security.

Related guides

SaaS & Cloud
SaaS & Cloud7 min read

What is RAM and what does it do: how much RAM is enough, memory types and a buying guide

When a computer slows down, RAM is the first suspect. We explain what RAM does, how it differs from storage and how many GB to choose for your needs.

SaaS & Cloud7 min read

What is open source: open source software, licenses, benefits and a guide to contributing to projects

Much technology, from Linux to browsers, is open source. We explain what open source is, how licenses differ and how you can contribute to projects.

SaaS & Cloud8 min read

SSD vs HDD: what's the difference and which should you choose? Speed, lifespan, durability, capacity and cost compared

An SSD is fast and silent, while an HDD offers large capacity cheaply. We explain how each works, their differences, NVMe vs SATA and which use each suits.

SaaS & Cloud9 min read

What is blockchain and how does it work? Uses, benefits, limits and common misunderstandings

Blockchain is a technology in which records are kept in a shared ledger that is hard to alter. We explain how it works, how it differs from crypto, real uses and its limits in plain language.

SaaS & Cloud9 min read

What is Linux? Distributions, how it differs from Windows and macOS, uses and a beginner's guide

Linux is an open-source operating system kernel that runs many of the world's servers and Android devices. We explain distributions, differences and steps for beginners.

Office & Productivity4 min read

What are mental models: thinking tools you can use to make better decisions

Decision-making gets easier with the right thinking tools. We explain the most useful mental models with everyday examples.