Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Git-GitHub-Basic

Added a comprehensive guide covering Git and GitHub concepts from beginner to advanced levels, including installation, basic commands, workflows, and best practices.

🚀 Git & GitHub Guide (Beginner → Advanced)

A simple, beginner-friendly guide to learn Git and GitHub step by step.


📌 1. What is Git?

Git is a tool that helps you:

  • Track changes in your code
  • Go back to previous versions
  • Work with others easily

👉 Think of Git like a save history for your project


🌍 2. What is GitHub?

GitHub is a website where you:

  • Store your Git projects online
  • Share code with others
  • Collaborate on projects

⚙️ 3. Install & Setup Git

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

Set your identity:

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

Check:

git config --list

📁 4. Create Your First Project

mkdir my-project
cd my-project
git init

👉 This creates a Git repository


🔄 5. Basic Workflow (Most Important)

git status
git add .
git commit -m "first commit"

Flow:

edit → add → commit

📜 6. View History

git log
git log --oneline

📂 7. Ignore Files

Create .gitignore

Example:

node_modules/
*.log
.env

🌿 8. Branching (Work Safely)

git branch
git checkout -b feature

Switch branch:

git checkout main

Merge:

git merge feature

🌍 9. Connect to GitHub

Create a repo on GitHub, then:

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

📥 10. Get Code from GitHub

git clone https://github.com/username/repo.git
git pull origin main

🔧 11. Undo Mistakes

Unstage:

git restore --staged file.txt

Discard changes:

git restore file.txt

Undo commit safely:

git revert HEAD

🚀 12. Intermediate Commands

Stash:

git stash
git stash pop

Check changes:

git diff

⚡ 13. Advanced Git

Rebase:

git rebase main

Cherry-pick:

git cherry-pick <commit-hash>

Tag:

git tag v1.0
git push origin v1.0

🧠 14. Important Concepts

Git has 3 areas:

  • Working Directory
  • Staging Area
  • Repository

Flow:

Working → Staging → Repository

⚔️ 15. Merge Conflicts

If conflict happens:

<<<<<<< HEAD
your code
=======
other code
>>>>>>> branch

👉 Fix manually → then:

git add .
git commit

🧩 16. Real Workflow (Industry Style)

git checkout -b feature-login
# work
git add .
git commit -m "add login"
git push origin feature-login

Then:

  • Create Pull Request on GitHub
  • Review
  • Merge

🛡️ 17. Best Practices

  • Commit small changes
  • Write clear messages
  • Pull before push
  • Don’t use --force on shared branches

🧪 18. Practice (Try This)

git init
echo "hello" > file.txt
git add .
git commit -m "first commit"
git log --oneline

🎯 Final Tip

Git is not about files.

👉 It is about tracking changes over time


⭐ If this helped you, give this repo a star!

About

Added a comprehensive guide covering Git and GitHub concepts from beginner to advanced levels, including installation, basic commands, workflows, and best practices.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors