Post

Git & GitHub Basics

A clear and structured revision guide covering Git and GitHub fundamentals, key concepts, workflows, and collaboration practices.

Git & GitHub Basics

🧠 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

TermDefinition
GitA 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.
GitHubA cloud-based platform for version control using Git, enabling code collaboration and repository hosting.
Open SourceSoftware whose source code is publicly accessible under a license permitting use, modification, and distribution.
CI/CDA 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 RepositoryA version of the repository stored on your computer for personal use and updates.
Remote RepositoryAn internet-based repository for sharing and collaboration.
CommitSaving your changes as snapshots to track progress and version history.
PushUploading your local commits to a remote repository to share with collaborators.
PullDownloading the latest updates from a remote repository to your local system.
CloneCreating 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.
SnapshotA 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

FeaturePurpose
Pull Requests (PRs)Propose changes and request that they be merged into another branch (usually main).
PR ReviewsTeam members can review, comment, and suggest modifications before approval.
MergingOnce 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:

  1. Open the conflicting file(s).
  2. Look for markers:

    1
    2
    3
    4
    5
    
    <<<<<<< HEAD
    your version
    =======
    collaborator’s version
    >>>>>>> branch-name
    
  3. Manually edit the file to retain the correct lines.
  4. Stage and commit the resolution:

    1
    2
    
    git add <filename>
    git commit -m "Resolve merge conflict"
    

🧪 Practical Example

During hands-on sessions, you can:

  1. Create a new repository (git init or via GitHub).
  2. Add and commit changes.
  3. Push them to GitHub:

    1
    
    git push origin main
    
  4. 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 status often — 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)

  1. Learn Git | Official — Understand version control, repositories, commits, and branches.

  2. Explore Git Commands | Official — Review official command references.

  3. GitHub Docs | Official — Learn GitHub workflows.

  4. Hello World Tutorial | GitHub Docs — Practice repository creation, commits, and pull requests.

  5. Git Tutorial | W3Schools — Beginner-friendly interactive guide.

  6. Git Cheat Sheet | Official — Quick reference of essential Git commands.

  7. Git Desktop documentation | Official — GitHub Desktop official documentation.

  8. Git Desktop on Linux | Unofficial — Installing GitHub Desktop on Linux (Unofficial, as of publishing date).

  9. Learn Git Branching | Comprehensive — Mastering Git commands, Visually.

  10. Learn Git and GitHub | Roadmap | Comprehensive - Roadmap to master Git and GitHub


This post is licensed under CC BY 4.0 by the author.