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!