Version control
- Git course
- Beginner
- Lesson 2/80
- 4 min
Learn how version control keeps the file history.
What is version control?
Version control is a method of recording and tracking changes made to files over time. You can view previous versions of a file, compare changes between different versions, and return to an earlier version when necessary. Git performs these operations through commit records.
git add app.js
git commit -m "Add validation"
git logThis system can be used not only in software projects but also with many other types of files where change history matters.
Commits and snapshots
When a commit is created, Git stores a record representing the project state at that moment. This approach is based on the snapshot concept. Unchanged file contents are not unnecessarily copied again; Git efficiently uses content references.
git add index.html
git commit -m "First version"
git add index.html
git commit -m "Update title"By creating multiple commits, you can track how a project evolves over time.
Practice Create two versions
First commit the notes.txt file with the message First content. Then stage the file changes and create a second commit with the message Second content. Both commits must belong to the same file.
Starter code
# İlk sürümü kaydet
# İkinci sürümü kaydetSample solution
# İlk sürümü kaydet
git add notes.txt
git commit -m "İlk içerik"
# İkinci sürümü kaydet
git add notes.txt
git commit -m "İkinci içerik"Expected output
[main b2c3d4e] İkinci içerik 1 file changed
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which is a key benefit of version control?
- Being able to track previous file versions Correct answer
- Automatically deleting files every time they open
- Converting all files into a single format
- Performing every remote operation without the internet
Explanation: Version control allows you to access previous versions and inspect when changes were made.
2 Create a change record
git add app.js
git commit -m "____"
git add app.js
git commit -m "İlk kayıt"
Explanation: A commit records staged changes in the history with a descriptive message.
3 Version control terminology
| Term | Meaning |
|---|---|
Version control |
Tracking changes |
History |
Previous records |
Snapshot |
Project state at a specific time |
Commit |
Recorded change |