Why We Need Git
Lesson information
Section titled “Lesson information”- Section: Git and GitHub
- Lesson: 1
- Duration: 8m 20s
Key concepts
Section titled “Key concepts”- What version control means
- Problems with manual file copies
- Tracking changes
- Collaboration between developers
What Goes Wrong Without Git
Section titled “What Goes Wrong Without Git”Before Git, developers often managed different versions of a project by manually copying files and creating folders with names such as:
project-finalproject-final-v2project-final-fixedproject-final-really-fixed
This approach quickly becomes confusing and unreliable, especially when several developers are working on the same project.
Git exists to replace this chaos with a tracked, organized, and reversible history of changes.
The Role of Git
Section titled “The Role of Git”Git helps developers track every change, protect their work, collaborate safely, and return to an earlier version whenever necessary.
The Solution: A Version Control System (VCS)
Section titled “The Solution: A Version Control System (VCS)”A Version Control System, commonly abbreviated as VCS, is a tool used in software development and collaborative projects to track and manage changes made to source code.
Instead of creating separate manual copies such as V1, V2, and V3, a
version control system stores the project’s changes in an organized history.
A Version Control System allows developers to:
- Track changes made to the source code.
- Keep a history of different project versions.
- Identify who made each change.
- Understand when and why a change was made.
- Return to an earlier version when necessary.
- Collaborate without overwriting each other’s work.
What Does “Distributed” Mean?
Section titled “What Does “Distributed” Mean?”“Distributed” means that every developer has a complete copy of the repository on their own computer, including the project files and the full history of changes.
This allows developers to work locally, create commits, and review previous changes without needing a permanent connection to a central server.
Save Points for Your Code
Section titled “Save Points for Your Code”Git commits are similar to checkpoints in a video game.
In a game, you save your progress at different checkpoints. You can continue playing, and if something goes wrong, you can return to the last saved checkpoint instead of restarting the entire game.
Git applies the same idea to source code. Each commit acts as a save point that records the project at a specific moment.
Example Development Timeline
Section titled “Example Development Timeline”Start
Empty project
The project has just been created.
Checkpoint
Login works
The login feature is complete and saved in a commit.
Checkpoint
Dark theme added
The dark theme is complete and saved in another commit.
You Are Here Now
Still coding
The developer is currently working on new changes.
If the current changes cause a problem, the developer can return to checkpoint 2 or checkpoint 3 without losing the earlier, working versions of the project.
What Is a Commit?
Section titled “What Is a Commit?”A commit is a saved snapshot of the project at a specific point in time.
Each commit contains the changes that were recorded at that moment, along with a message explaining what was changed.
Commits allow developers to:
- Save meaningful stages of their work.
- Review previously recorded changes.
- Compare different versions of the project.
- Return to an earlier stable version.
- Understand how the project developed over time.
A commit is not the same as saving a file with
Ctrl + S.
Ctrl + Ssaves the current file on your computer, while a Git commit records a meaningful version of the project in Git’s history.