🛠️Comprehensive Git Guide: Master Version Control as a Developer

Table of contents

Understanding Version Control Systems (VCS) with Git
In the world of software development, Version Control Systems (VCS) solve two critical problems: sharing and versioning. When multiple developers collaborate on the same codebase, tracking changes, integrating features, and maintaining history becomes essential. That’s where tools like Git shine.
🚀 What is a Version Control System?
A Version Control System tracks every change made to a file or folder over time. Imagine a developer creates a file on Day 1, modifies it on Day 2, deletes some content on Day 3, and adds new code on Day 4. With a VCS, they can inspect each change, even recovering deleted lines or reviewing modifications from any specific day.
🔄 Centralized vs. Distributed Version Control
Centralized VCS
Tools like CVS and SVN are examples of centralized version control systems. They work on a single central server, which stores all versions of the code. If developers want to collaborate, they must pull and push code through this server, meaning the central server is always the single source of truth.
Distributed VCS
Git, on the other hand, is a distributed VCS. Each developer has a full copy of the repository, including its entire history. They can:
Work offline
Commit changes locally
Review history independently
When they’re ready, developers push their changes to the central remote repository for review and collaboration.
đź§° Key Git Terminology and Commands
Initial Setup
Initialize a repository
git init
This creates a
.git
directory that stores all version control information.Check repository changes
git diff
Commit changes
git commit
Each commit stores what changed, who made the change, and when.
View commit history
git log
Reset to a previous commit
git reset --hard <commit-id>
đź”— Working with Remote Repositories
After initializing a local Git repository, pushing to a remote requires linking it:
Add a remote reference
git remote add origin <repository-URL>
Check remote reference
git remote -v
If you clone a repository using git clone
, the remote reference is automatically set up, allowing you to push without adding it manually.
🔑 Using HTTPS vs. SSH
To clone a repository, you can use either:
HTTPS: Prompts for username and password.
SSH: Uses public-private key authentication.
Generate SSH Keys
ssh-keygen -t rsa
This will generate keys in the .ssh
folder. Add the public key to GitHub via:
GitHub → Settings → SSH and GPG Keys
🔄 Clone vs. Fork
Operation | Purpose | Remote Connection |
Clone | Copies repo locally; changes are pushed to the same remote | Yes |
Fork | Creates a separate copy under your GitHub account | No direct link to original repo |
🌿 Branching and Merging
View logs of another branch
git log <branch-name>
Cherry-pick specific commits
git cherry-pick <commit-id>
This allows selective commit merging from one branch to another.
Merge vs. Rebase
Merge: Combines histories; keeps commits from both branches.
Rebase: Rewrites history; applies commits from the feature branch before the base branch commits.
Example:
git merge feature-branch
# vs.
git rebase feature-branch
đź§ Conclusion
Version Control Systems like Git are indispensable for modern software development. They allow developers to:
Track changes efficiently
Collaborate without overwriting others’ work
Safely experiment with new features
Platforms like GitHub, GitLab, and Bitbucket enhance Git by offering intuitive user interfaces, collaboration tools, and project management capabilities. Mastering Git fundamentals is a must-have skill for every developer.
Subscribe to my newsletter
Read articles from Pranay Miriyala directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Pranay Miriyala
Pranay Miriyala
Hi, I’m Pranay Miriyala — a DevOps and platform engineering enthusiast who documents what I learn as I grow in the world of infrastructure, automation, and software systems. Through DevOpsLogs, I share practical insights, lessons, and guides on tools, practices, and architecture that power modern engineering teams.