Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 183 additions & 0 deletions GITHUB_CHEATSHEET.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# 🧾 Git & GitHub Cheat Sheet (Complete Contribution Guide)

This cheat sheet explains how a user actually works with Git and GitHub in real life.
It covers the full contribution process: forking a repository, making changes, committing,
and creating a pull request.

---

## 📁 Step 1: Fork the Repository (GitHub)

**What you do:**
You click the **Fork** button on GitHub.

**Why this is needed:**
You cannot directly change someone else’s repository.
Forking creates your own copy of the project under your GitHub account.

This is always the first step when contributing to open-source projects.

---

## 📂 Step 2: Clone the Forked Repository

git clone <your-forked-repository-url>

**What you do:**
You download your forked repository to your local system.

**Why this is needed:**
All code changes are made on your computer before being uploaded to GitHub.

---

## 🌿 Step 3: Create a New Branch

git checkout -b feature-branch

**What you do:**
You create a new branch for your work.

**Why this is needed:**
Branches keep your changes separate from the main code.
This prevents breaking the main project and is required in professional workflows.

---

## ✏️ Step 4: Make Changes to the Code or Files

**What you do:**
You edit files using your code editor (VS Code, etc.).

**Why this is needed:**
This is where you actually fix bugs, add features, or improve documentation.

Git does not track changes automatically—you must check and save them explicitly.

---

## 🔍 Step 5: Check Your Changes

git status
git diff

**What you do:**
You review what files were changed and what exactly was modified.

**Why this is needed:**
This helps avoid committing unwanted or incorrect changes.

---

## 📝 Step 6: Stage the Changes

git add .

**What you do:**
You tell Git which changes are ready to be saved.

**Why this is needed:**
Only staged files are included in a commit.
This gives you control over what gets saved.

---

## 💾 Step 7: Commit the Changes

git commit -m "Describe what you changed"

**What you do:**
You permanently save the staged changes with a clear message.

**Why this is needed:**
Commits create a history of changes so others can understand what was done and why.

Each commit should represent one meaningful change.

---

## 🔄 Step 8: Sync With the Original Repository

git pull upstream main

**What you do:**
You bring the latest changes from the original repository into your branch.

**Why this is needed:**
This helps avoid conflicts and ensures your work is based on the latest version.

---

## ⬆️ Step 9: Push Changes to Your Fork

git push origin feature-branch

**What you do:**
You upload your committed changes to your fork on GitHub.

**Why this is needed:**
Your changes must be on GitHub before you can request them to be merged.

---

## 🚀 Step 10: Create a Pull Request (PR)

**What you do:**
You open GitHub and click **New Pull Request**.

**Why this is needed:**
A Pull Request asks the project maintainers to review your changes.
They may approve, request changes, or reject the contribution.

This is how collaboration happens on GitHub.

---

## 📜 Step 11: View Commit History (Optional)

git log
git log --oneline

**What this does:**
Shows all previous commits and helps track changes over time.

---

## 📦 Step 12: Temporarily Save Work (Optional)

git stash
git stash pop

**What this does:**
Allows you to temporarily save unfinished work when switching branches.

---

## 🚫 Step 13: Ignore Unnecessary Files

node_modules/
.env
*.log

**Why this is needed:**
These files should not be uploaded to GitHub.
They are listed inside a `.gitignore` file to keep the repository clean and secure.

---

## ✅ Step 14: Good Contribution Practices

- Always work on a separate branch
- Write clear and meaningful commit messages
- Pull latest changes before pushing
- Follow the project’s CONTRIBUTING.md file

These practices make your contribution professional and acceptable.

---

### 📌 Final Note

This cheat sheet explains the **complete, real-world GitHub contribution process**
from a user’s point of view, not just commands.
It is suitable for beginners, college assignments, and open-source contributions.