Added a comprehensive guide covering Git and GitHub concepts from beginner to advanced levels, including installation, basic commands, workflows, and best practices.
A simple, beginner-friendly guide to learn Git and GitHub step by step.
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
GitHub is a website where you:
- Store your Git projects online
- Share code with others
- Collaborate on projects
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 --listmkdir my-project
cd my-project
git init👉 This creates a Git repository
git status
git add .
git commit -m "first commit"Flow:
edit → add → commit
git log
git log --onelineCreate .gitignore
Example:
node_modules/
*.log
.env
git branch
git checkout -b featureSwitch branch:
git checkout mainMerge:
git merge featureCreate a repo on GitHub, then:
git remote add origin https://github.com/username/repo.git
git push -u origin maingit clone https://github.com/username/repo.git
git pull origin mainUnstage:
git restore --staged file.txtDiscard changes:
git restore file.txtUndo commit safely:
git revert HEADStash:
git stash
git stash popCheck changes:
git diffRebase:
git rebase mainCherry-pick:
git cherry-pick <commit-hash>Tag:
git tag v1.0
git push origin v1.0Git has 3 areas:
- Working Directory
- Staging Area
- Repository
Flow:
Working → Staging → Repository
If conflict happens:
<<<<<<< HEAD
your code
=======
other code
>>>>>>> branch
👉 Fix manually → then:
git add .
git commitgit checkout -b feature-login
# work
git add .
git commit -m "add login"
git push origin feature-loginThen:
- Create Pull Request on GitHub
- Review
- Merge
- Commit small changes
- Write clear messages
- Pull before push
- Don’t use
--forceon shared branches
git init
echo "hello" > file.txt
git add .
git commit -m "first commit"
git log --onelineGit is not about files.
👉 It is about tracking changes over time
⭐ If this helped you, give this repo a star!