Git protects your work, explains your progress, and makes collaboration possible.
Git is not just an upload tool. It is your history system. It shows what changed, when it changed, and why it changed. This page takes you from a first local repo to the core commands you need for real team work.
What Git actually tracks
Working directory
The files you are editing now.
Staging area
The files you intentionally prepare for the next commit.
Commit history
Saved checkpoints with messages that explain the change.
Remote
A hosted copy, usually on GitHub, where collaboration and backup happen.
git status -> add what belongs together -> commit with a useful message -> push when ready.
Activity 1: Create your first repo
mkdir git-practice cd git-practice git init echo "# Git Practice" > README.md git status git add README.md git commit -m "Add initial README"
git status should say your working tree is clean.The commands you will use the most
See changes
git status
Add selected files
git add README.md # or git add .
Commit
git commit -m "Explain what changed"
See history
git log --oneline
See unstaged diffs
git diff
See staged diffs
git diff --staged
Use branches when a change deserves its own lane
git branch feature-homepage git switch feature-homepage # make changes git add . git commit -m "Build homepage draft"
Check branches with:
git branch
Switch back:
git switch main
Connect to GitHub and push
git remote add origin https://github.com/yourname/your-repo.git git branch -M main git push -u origin main
After this, future pushes are often just:
git push
When other people or GitHub have newer work
git pull
If you only want the latest remote info first:
git fetch
Then inspect and merge intentionally.
Use a .gitignore early
Create a file named .gitignore and add things that should not be committed.
__pycache__/ *.pyc .env node_modules/ .vscode/
Adjust it for your actual project. The point is to keep history focused on real source files.
Safe beginner rescue commands
git restore --staged filenamegit restore filenamegit log --oneline --decorate --graph