Table of Contents

Introduction to Version Control
In modern software development, managing code changes efficiently is critical. Version control systems help developers track changes, collaborate with teams, and maintain a history of their work. Among these systems, Git and GitHub are the most widely used tools in the industry today.
Git is a distributed version control system, while GitHub is a cloud-based platform that hosts Git repositories and adds collaboration features. Together, they form the backbone of modern DevOps and software development workflows.
What is Git?
Git is an open-source distributed version control system created by Linus Torvalds in 2005. It allows developers to track changes in source code, revert to previous versions, and work simultaneously on the same project without conflicts.
Key Features of Git
- Distributed architecture (every developer has a full copy of the repository)
- Fast and efficient performance
- Powerful branching and merging
- Complete history tracking
What is GitHub?
GitHub is a web-based hosting service for Git repositories. It provides a graphical interface and collaboration tools such as pull requests, issues, and project boards.
Key Features of GitHub
- Remote repository hosting
- Team collaboration and access control
- Pull requests for code review
- Issue tracking and project management
- CI/CD integration via GitHub Actions
Git vs GitHub: Understanding the Difference
| Git | GitHub |
| Version control system | Hosting and collaboration platform |
| Works locally | Cloud-based |
| Command-line focused | Web interface + Git |
| Tracks code changes | Manages teamwork and sharing |
Installing and Setting Up Git
Installing Git
- Windows / macOS / Linux: Download from the official Git website
- Verify installation:
git --version
Initial Configuration
git config --global user.name "Your Name"git config --global user.email "youremail@example.com"git config --list
Creating and Managing a Git Repository
Initialize a Repository
git init
Check Repository Status
git status
Add Files to Staging Area
git add filenamegit add .
Commit Changes
git commit -m "Initial commit"
Working with Git History
View Commit History
git loggit log --oneline
View File Differences
git diffgit diff --staged
Undo Changes
git checkout -- filenamegit reset HEAD filenamegit revert commit_id
Branching and Merging in Git
Branches allow parallel development without affecting the main codebase.
Create and Switch Branches
git branchgit branch feature-branchgit checkout feature-branchgit checkout -b new-branch
Merge Branches
git checkout maingit merge feature-branch
Delete Branches
git branch -d branch-name
Connecting Git with GitHub
Create a Remote Repository
Create a repository on GitHub, then link it to your local project:
git remote add origin https://github.com/username/repo.gitgit remote -v
Push Code to GitHub
git push origin main
Clone a Repository
git clone https://github.com/username/repo.git
Pull Latest Changes
git pull origin main
Collaboration Using GitHub
- Forking – Forking creates a personal copy of another repository, allowing independent development.
- Pull Requests – Pull requests allow developers to propose changes and request reviews before merging into the main branch.
- Issues – Issues are used to track bugs, feature requests, and tasks.
Advanced Git Commands
Stashing Changes
git stashgit stash applygit stash list
Tagging Releases
git tag v1.0git tag
Resetting Commits
git reset --soft HEAD~1git reset --hard HEAD~1
Rewriting History
git rebase main
Best Practices for Using Git and GitHub
- Commit frequently with meaningful messages
- Use branches for new features and fixes
- Pull latest changes before pushing
- Review code using pull requests
- Keep repositories clean and well-documented
Conclusion
Git and GitHub have become essential tools for developers, enabling efficient version control and seamless collaboration. Git provides powerful control over code history, while GitHub enhances teamwork through cloud hosting and collaboration features. Mastering Git commands and GitHub workflows is a critical skill for anyone pursuing software development, DevOps, or open-source contribution.
With consistent practice and proper workflows, Git and GitHub can significantly improve productivity, code quality, and project management.

