​​​​​​​Version Control with Git and GitHub

​​​​​​​Version Control with Git and GitHub

Understand how developers track and collaborate on code step by step.


🔹 What is Version Control?

Version control is a system that:

  • Tracks changes to files over time

  • Lets multiple people work on the same project without overwriting each other

  • Stores history so you can go back to previous versions

✅ Used for coding, writing, documents, designs — anything that changes over time.


🔹 What is Git?

Git is a version control system — a tool you install on your computer.
It helps you:

  • Track code changes

  • Manage multiple versions (branches)

  • Collaborate with others

  • Undo mistakes

🛠️ Git works locally (on your computer) and is free & open-source.


🔹 What is GitHub?

GitHub is a cloud platform that:

  • Stores Git repositories (your project folders)

  • Lets you collaborate online

  • Adds features like bug tracking, pull requests, and project management

📌 Think:
Git = tool
GitHub = online service for sharing Git projects


🧭 Git + GitHub: Step-by-Step Workflow


🔸 Step 1: Install Git

  • Go to https://git-scm.com

  • Download and install Git for your OS (Windows, macOS, Linux)

  • Open your terminal and run:

git --version

✅ If it shows a version, Git is installed.


🔸 Step 2: Configure Git (first time only)

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

🔸 Step 3: Create a Git Repository (repo)

A repository is your project folder that Git will track.

mkdir my-project
cd my-project
git init

✅ Now Git is tracking your folder.


🔸 Step 4: Make Changes and Save Versions

Create a file:

echo "Hello World" > hello.txt

Then:

git add hello.txt      # Stage the file
git commit -m "Add hello.txt"  # Save the version

🔸 Step 5: View History

git log

📜 Shows all commits (versions) with dates, messages, and author info.


🔸 Step 6: Create a GitHub Repository

  • Go to https://github.com

  • Click ➕ “New Repository”

  • Give it a name (e.g., my-project)

  • Click Create repository


🔸 Step 7: Push Your Code to GitHub

In terminal (after creating the repo on GitHub):

git remote add origin https://github.com/yourusername/my-project.git
git branch -M main
git push -u origin main

✅ Your local code is now online on GitHub.


🔁 Common Git Commands

Command Description
git status Shows current changes
git add file.txt Adds file to staging
git commit -m "Message" Saves changes with message
git push Uploads to GitHub
git pull Downloads latest version from GitHub
git clone URL Copies a project from GitHub to your PC

🌱 Branches

Branches let you try new ideas without changing the main code.

git checkout -b new-feature

Later you can merge it into main:

git checkout main
git merge new-feature

🤝 GitHub Collaboration Features

  • Pull requests — suggest changes to others’ code

  • 💬 Issues — report bugs, request features

  • 📂 Forks — copy someone else’s repo to your account

  • 🔄 Merge — apply changes from one branch into another


🔒 Private vs Public Repos

  • Public — anyone can see and fork your code

  • Private — only invited users can see


📦 Real-Life Use Cases

Use Case Example
Solo project Track your own app
Teamwork Multiple devs coding together
Open source Contribute to popular tools (React, Django, etc.)
Education Students share homework and feedback

🔚 Summary

Term Meaning
Git Local version control tool
GitHub Online code hosting platform
Repo A tracked project
Commit A saved snapshot
Push Upload changes to GitHub
Pull Download updates from GitHub
Branch A separate version of your code

Note: All information provided on the site is unofficial. You can get official information from the websites of relevant state organizations