Skip to content

roseewood/Learn-GitHub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Learn GitHub

Welcome to the ultimate GitHub learning guide.
This README is designed so that anyone can learn Git + GitHub from zero to advanced, simply by reading it.

  • Clear explanations
  • Examples
  • Diagrams
  • Tables
  • Best practices
  • Advanced concepts
  • Real workflows

πŸ“˜ What Are Git & GitHub?

πŸ”§ What is Git?

Git is a distributed version control system (VCS). It helps developers:

  • Track changes in code
  • Restore previous versions
  • Work on features safely
  • Collaborate without overwriting code

Think of Git as a time-machine + teamwork tool for code.

πŸ’» What is GitHub?

GitHub is an online platform built on top of Git. It provides:

  • Cloud hosting for repositories
  • Collaboration tools
  • Automation (CI/CD)
  • Project management
  • Documentation hosting
Git = Version control
GitHub = Social network + cloud for Git projects

πŸ›  Installing & Configuring Git

Step 1: Install Git

Download Git from: https://git-scm.com/downloads

git --version

Step 2: Configure Git (Required)

git config --global user.name "Your Name"
git config --global user.email "your@email.com"

πŸ“ Repositories β€” Local & Remote

A repository (repo) is a folder tracked by Git.

Two types:

  • Local repository (on your computer)
  • Remote repository (on GitHub)

Create a Local Repository

mkdir my-project
cd my-project
git init

Create a Remote Repository (GitHub)

  1. Log in β†’ Click New Repository
  2. Enter a name
  3. Click Create

Link Local β†’ GitHub

git remote add origin https://github.com/username/repo.git
git push -u origin main

πŸ“„ Understanding Git Workflow

Diagram: Local β†’ GitHub Workflow

A[Working Directory] β†’ git add β†’ Staging Area β†’ git commit β†’ Local Repo β†’ git push β†’ GitHub Remote Repo

🧱 Essential Git Commands

Command Purpose
git initStart a new repo
git cloneCopy a GitHub repo
git addStage changes
git commitSave changes
git statusShow file states
git pushUpload to GitHub
git pullDownload from GitHub
git logShow commit history

πŸ” Commit, Push & Pull (Core Git Flow)

git add .
git commit -m "Describe what you changed"
git push origin main
git pull origin main

🌿 Branching β€” Safe Way to Build Features

Create a branch

git checkout -b login-feature

Switch branches

git checkout main

Merge branch

git merge login-feature

Delete branch

git branch -d login-feature

πŸ“₯ Pull Requests (PRs) β€” Collaboration Workflow

Pull Requests allow:

  • Reviewing code
  • Discussing changes
  • Running automated tests
  • Merging feature branches
  1. Push your branch
  2. Go to Pull Requests
  3. Click New Pull Request
  4. Write title & description
  5. Add reviewers
  6. Submit

🀝 Collaboration β€” Forks & Clones

Clone a repo

git clone https://github.com/user/repo.git

Forking

Fork = Copy someone’s repo into your GitHub

Add upstream (original repo)

git remote add upstream https://github.com/original/repo.git

Sync fork

git fetch upstream
git merge upstream/main

πŸ’Ό Issues, Labels, & Milestones

Issues Used For

  • Bugs 🐞
  • Feature requests ✨
  • Questions ❓
  • Tasks πŸ“Œ

Labels

LabelMeaning
bugSomething not working
enhancementNew feature
documentationDocs needed
good-first-issueBeginner friendly

πŸ§ͺ GitHub Actions β€” Automation & CI/CD

Example Workflow

name: CI
on: [push]

jobs:
 build:
  runs-on: ubuntu-latest
  steps:
   - uses: actions/checkout@v2
   - name: Install Packages
     run: npm install
   - name: Run Tests
     run: npm test

🌐 GitHub Pages β€” FREE Website Hosting

  1. Go to Settings β†’ Pages
  2. Select a branch
  3. Save

Your website will appear at:

https://username.github.io/repository-name


🧠 Advanced Git Concepts

Soft Reset (keep changes)

git reset --soft HEAD~1

Hard Reset (delete changes)

git reset --hard HEAD~1

Stash (temporary save)

git stash
git stash list
git stash pop

Rebase

git rebase main

Cherry-pick

git cherry-pick <commit-id>

Tags

git tag v1.0.0
git push origin v1.0.0

🚨 Best Practices Every Developer Should Follow

  • Commit small & frequently
  • Write meaningful commit messages
  • Use branches for each feature
  • Use PRs & request reviews
  • Keep main always stable
  • Automate tests with GitHub Actions
  • Document everything

πŸ“š Useful Resources



Happy Coding! βœ¨πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

About

Learn GitHub, Open Source and Collaboration.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors