Git & GitHub Basics
A clear and structured revision guide covering Git and GitHub fundamentals, key concepts, workflows, and collaboration practices.
🧠 Git & GitHub Basics
📘 Understanding Git & GitHub
🔹 What is Git?
Git is a Version Control System (VCS) that allows you to manage changes to your code and collaborate with others on projects efficiently.
✳️ Key Features
- Version Control: Enables users to track the history of changes and revert to previous versions if necessary.
- Distributed System: Unlike centralized systems, Git gives each collaborator a local copy of the entire project history — enhancing data reliability and flexibility.
🧩 Git Terminologies
| Term | Definition |
|---|---|
| Git | A distributed version control system (VCS) that records changes to files and enables multiple developers to collaborate on a project by maintaining complete version histories locally and remotely. |
| GitHub | A cloud-based platform for version control using Git, enabling code collaboration and repository hosting. |
| Open Source | Software whose source code is publicly accessible under a license permitting use, modification, and distribution. |
| CI/CD | A development practice combining Continuous Integration (automated code testing and merging) and Continuous Deployment (automated code delivery to production). |
| VCS (Version Control System) | A system that manages and records changes to files over time, allowing restoration, comparison, and collaborative editing. |
| Repository (Repo) | A storage area for project files, acting like a project folder. |
| Local Repository | A version of the repository stored on your computer for personal use and updates. |
| Remote Repository | An internet-based repository for sharing and collaboration. |
| Commit | Saving your changes as snapshots to track progress and version history. |
| Push | Uploading your local commits to a remote repository to share with collaborators. |
| Pull | Downloading the latest updates from a remote repository to your local system. |
| Clone | Creating a local copy of a repository from a remote source. |
| Pull Request (PR) | A formal request to merge code changes from one branch into another within a version-controlled repository. |
| Snapshot | A complete record of the project’s state at a specific point in time, created when a commit is made in Git. |
🌐 Understanding GitHub
GitHub is a web-based platform that leverages Git for version control.
It allows hosting repositories online for collaboration, contribution, and backup.
It serves as a social platform for developers, encouraging open-source development and community contributions, where users can fork, clone, and collaborate on projects with ease.
⚙️ Workflows in Git and GitHub
1. 🏗️ Creating a Repository
- You can create a repository locally using:
1
git init
- Or on GitHub, by clicking “New Repository”, naming it, and optionally initializing it with a
README.md.
2. 💾 Committing Changes
Each time you make meaningful code updates:
1
2
git add .
git commit -m "Add initial project files"
💡 Commits act as snapshots of your project, recording progress over time.
3. 🌿 Branching and Merging
Branches allow independent development of features without affecting the main code base.
1
2
3
4
5
6
git branch feature-login
git checkout feature-login
# make changes
git commit -m "Add login feature"
git checkout main
git merge feature-login
Merging integrates the changes back into the main project.
🤝 Collaboration Features
| Feature | Purpose |
|---|---|
| Pull Requests (PRs) | Propose changes and request that they be merged into another branch (usually main). |
| PR Reviews | Team members can review, comment, and suggest modifications before approval. |
| Merging | Once approved, changes are merged into the main branch, integrating new features or fixes. |
⚠️ Managing Conflicts
When multiple collaborators modify the same section of a file, merge conflicts can occur.
To resolve:
- Open the conflicting file(s).
Look for markers:
1 2 3 4 5
<<<<<<< HEAD your version ======= collaborator’s version >>>>>>> branch-name
- Manually edit the file to retain the correct lines.
Stage and commit the resolution:
1 2
git add <filename> git commit -m "Resolve merge conflict"
🧪 Practical Example
During hands-on sessions, you can:
- Create a new repository (
git initor via GitHub). - Add and commit changes.
Push them to GitHub:
1
git push origin main
- Create feature branches and practice merging to reinforce Git fundamentals.
🧾 Summary
This guide provides a clear and structured understanding of Git and GitHub essentials.
- Git handles version control and local project tracking.
- GitHub enables collaboration, hosting, and open-source contribution.
- Learn to use essential commands:
git init → git add → git commit → git push → git pull → git merge.
By following these workflows and examples, learners can manage codebases efficiently and collaborate with peers seamlessly — an essential skill set for software developers, data scientists, and ML engineers alike.
💡 Pro Tip:
Use
git statusoften — it helps verify what’s staged, unstaged, or untracked before committing changes.
🧭 Follow this sequence — Git first, GitHub next — to build practical understanding step-by-step.
📚 References (Git → GitHub Workflow)
Learn Git | Official — Understand version control, repositories, commits, and branches.
Explore Git Commands | Official — Review official command references.
GitHub Docs | Official — Learn GitHub workflows.
Hello World Tutorial | GitHub Docs — Practice repository creation, commits, and pull requests.
Git Tutorial | W3Schools — Beginner-friendly interactive guide.
Git Cheat Sheet | Official — Quick reference of essential Git commands.
Git Desktop documentation | Official — GitHub Desktop official documentation.
Git Desktop on Linux | Unofficial — Installing GitHub Desktop on Linux (Unofficial, as of publishing date).
Learn Git Branching | Comprehensive — Mastering Git commands, Visually.
Learn Git and GitHub | Roadmap | Comprehensive - Roadmap to master Git and GitHub