📌 What is Version Control?
Version Control is a system that records changes to files over time so that you can recall specific versions later.
It helps in:
- Tracking file changes
- Collaborating with teams
- Rolling back to previous versions
- Branching and merging code for new features or fixes
🧠 Types of Version Control
Type | Description | Examples |
---|---|---|
Local VCS | Tracks changes on a local machine | RCS (Revision Control System) |
Centralized VCS (CVCS) | One central server; all clients pull/push from it | CVS, Subversion (SVN), Perforce |
Distributed VCS (DVCS) | Every client has a complete repo with full history | Git, Mercurial |
🔧 Popular Version Control Systems
VCS | Description |
---|---|
Git | Most widely used, distributed, supports local commits and branching |
SVN | Centralized, still used in some enterprise systems |
Mercurial | DVCS similar to Git, simpler interface |
Perforce | Enterprise-level CVCS, high performance |
TFS / Azure DevOps | Version control + project tracking (by Microsoft) |
🧰 Git Basics (Most Popular VCS)
Command | Description |
---|---|
git init | Initialize a Git repository |
git clone [url] | Clone a remote repository |
git status | Show current state of the repo |
git add [file] | Stage changes |
git commit -m "message" | Commit staged changes |
git push | Push commits to remote repo |
git pull | Fetch + merge changes from remote |
git branch | List branches |
git checkout [branch] | Switch to another branch |
git merge [branch] | Merge another branch into current |
git log | View commit history |
🌿 Git Branching Model
Branch | Purpose |
---|---|
main or master | Production-ready code |
develop | Integration branch for features |
feature/* | New features in development |
release/* | Pre-release testing/stabilization |
hotfix/* | Urgent fixes for production bugs |
📦 Git Hosting Services
Platform | Features |
---|---|
GitHub | Open source, collaboration, Actions (CI/CD) |
GitLab | DevOps pipeline built-in |
Bitbucket | Integrates with Jira, supports Git & Mercurial |
Azure Repos | Microsoft’s cloud-based Git/SVN hosting |
🛠️ Best Practices
- Commit often with meaningful messages
- Use branches for features and fixes
- Pull and review before pushing
- Avoid committing secrets/passwords
- Use
.gitignore
to exclude unnecessary files - Merge with pull requests and code reviews
📚 Tools & GUIs
Tool | Description |
---|---|
GitKraken, Sourcetree | Git desktop clients |
VS Code Git panel | Built-in Git UI |
Git CLI | Core Git commands |
GitHub Desktop | Easy GitHub integration |
📘 Learn More
- Git official: https://git-scm.com/
- GitHub Docs: https://docs.github.com/
- Atlassian Git Tutorials: https://www.atlassian.com/git