Version Control Systems
10. Version Control Systems
a. Introduction to Git
Git is a version control system that tracks changes to your code over time. It lets you move backward and forward through history, see who changed what, and work with others safely.
Instead of copying whole project folders manually, Git stores snapshots of your files and metadata about each change. This makes collaboration and rollback far easier than ad‑hoc methods.
Using Git becomes essential as soon as your project is more than a simple script. It protects you from losing work and gives you confidence to experiment.
b. Git Commands
Git commands let you interact with the repository. Some core commands include:
- git init to start a repository
- git add to stage changes
- git commit to save a snapshot
- git status to see current changes
- git log to view history
These commands form the basic workflow: edit files, stage them, commit them, and repeat. Over time you add more advanced commands, but these basics cover a lot of everyday use.
Running these commands frequently makes your history granular and meaningful. Each commit becomes a small, understandable step.
c. Branching and Merging
Branches allow you to create separate lines of development. Instead of changing main directly, you create a branch for a feature or bug fix. This keeps experimental or unstable changes isolated.
Merging brings changes from one branch into another. After finishing a feature, you merge it into main so others can use it. If both branches changed the same parts of a file, you may need to resolve conflicts manually.
Branching and merging support parallel work. Multiple people can develop features independently and then integrate them in a controlled way.
d. GitHub Basics
GitHub is a hosting platform for Git repositories. It adds collaboration features like pull requests, issue tracking, and code reviews on top of Git.
With GitHub, you can:
- Push your local repository to a remote
- Share code with others
- Review changes before merging
- Use CI/CD and other integrations
Even for solo projects, GitHub provides backup, history, and a convenient place to showcase your work. For teams, it becomes the central hub of collaboration.
Git vs Manual Backups
Aspect | Git | Manual Copy/Paste Backups |
| Change tracking | Detailed history and messages | Hard to know what changed |
| Collaboration | Built-in merging and branches | Very limited, prone to conflicts |
| Rollback | Easy to revert to specific commit | Hard to restore exact versions |
| Storage efficiency | Stores differences, not full copies | Often multiple full copies |










