
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?
| Concept | Meaning |
|---|---|
| Git | The version control tool that runs on your computer |
| GitHub / GitLab | Services 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
| Concept | Meaning |
|---|---|
| Repository | The project's files and all their history |
| Commit | A snapshot of changes saved with a message |
| Branch | An independent line of development apart from the main line |
| Merge | Combining one branch into another |
| Clone | Copying a remote repository to your computer |
| Push / Pull | Sending changes to / getting them from the remote repository |
| Staging | The area where you pick the changes that go into a commit |
- 1
You make changes to files
- 2
You choose which changes to record (add)
- 3
You create a commit with a descriptive message
- 4
You send the changes to the remote repository (push)
- 5
You pull others' changes (pull)
Basic commands
| Command | Function |
|---|---|
git init | Starts a new repository |
git clone url | Copies an existing repository |
git status | Shows the state |
git add file | Stages a change |
git commit -m "message" | Creates a commit |
git log | Lists history |
git branch and git switch | Lists and switches branches |
git merge branch | Merges a branch |
git pull / git push | Gets 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
- Make small, focused commits.
- Write a descriptive message: what changed and why?
- Don't push broken code to the main branch.
- Push often; it doubles as a backup.
- Don't put secrets in the repository: passwords, API keys and .env files (see our API key security guide).
- 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
- Making huge, mixed commits.
- Writing meaningless messages ("fix").
- Pushing secrets.
- Working directly on the main branch.
- 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.
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.