Git is a version control system used to track changes in your code, collaborate with others, and manage project history efficiently.
1๏ธโฃ What is Git?
Git lets you save snapshots of your code, go back to previous versions, and collaborate with teams without overwriting each otherโs work. ๐ธ
2๏ธโฃ Install & Setup Git
git --version # Check if Git is installedgit config --global user.name "Your Name"git config --global user.email "you@example.com"3๏ธโฃ Initialize a Repository
git init # Start a new local Git repo ๐4๏ธโฃ Basic Workflow
git add . # Stage all changes โgit commit -m "Message" # Save a snapshot ๐พgit push # Push to remote (like GitHub) โ๏ธ5๏ธโฃ Check Status & History
git status # See current changes ๐ฆgit log # View commit history ๐6๏ธโฃ Clone a Repo
git clone https://github.com/username/repo.git ๐ฏ7๏ธโฃ Branching
git branch feature-x # Create a branch ๐ณgit checkout feature-x # Switch to it โ๏ธgit merge feature-x # Merge with main branch ๐ค8๏ธโฃ Undo Mistakes โฉ๏ธ
git checkout -- file.txt # Discard changesgit reset HEAD~1 # Undo last commit (local)git revert <commit_id> # Revert commit (safe)9๏ธโฃ Working with GitHub
โ Create repo on GitHub โจ
โ Link local repo:
git remote add origin <repo_url>git push -u origin main๐ Git Best Practices
โ Commit often with clear messages โ
โ Use branches for features/bugs ๐ก
โ Pull before push ๐
โ Never commit sensitive data ๐
๐ก Tip: Use GitHub Desktop or VS Code Git UI if CLI feels hard at first.
๐ฌ Tap โค๏ธ for more!