Git is a tool that tracks changes in your code. GitHub is where you store and share that code online.
Think of Git as your project's save history — and GitHub as the cloud backup.
Download from git-scm.com and install.
Verify:
git --version
Tell Git who you are before using it:
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
This name and email appears on every commit you make.
Every time you work on a project, you follow these steps:
cd your-project
git init
git status
git add . # Stage everything
git add file.txt # Stage one file
git commit -m "describe what you did"
Good commit messages: "add login page", "fix navbar bug", "update README"
git remote add origin https://github.com/username/repo.git
git branch -M main
git push -u origin main
Next time you push, just:
git push
git pull # Get latest changes from GitHub
git log # View commit history
git clone <url> # Download a GitHub repo
git diff # See what changed since last commit
Working files → git add → Staged → git commit → Local repo → git push → GitHub
Every commit is a snapshot. You can always go back to any previous commit.
fatal: not a git repository
→ You forgot git init. Run it in your project folder.
rejected — non-fast-forward
→ Someone else pushed changes. Run git pull first, then push.
Permission denied (publickey)
→ GitHub no longer accepts passwords. Set up SSH or use a Personal Access Token.