Version control records changes to files over time. You can revert files to previous versions, compare changes, see who modified what, and collaborate without overwriting each other's work. Git is distributed — everyone has a full copy of the repository.
Install Git from git-scm.com. Configure your identity: git config --global user.name "Your Name" and git config --global user.email "[email protected]". Check your settings with git config --list.
The basic cycle: git init (create repository), git add . (stage changes), git commit -m "message" (save snapshot). Use git status to see current state. git log shows commit history. The three states: working directory, staging area, repository.
Branches let you develop features independently. git branch feature-name creates a branch. git checkout feature-name switches to it. git checkout -b new-feature creates and switches in one command. Merge with git merge feature-name (switch to main first).
Clone a repo: git clone https://github.com/user/repo.git. Push changes: git push origin main. Pull updates: git pull origin main. Add remote: git remote add origin
Commit early, commit often — small focused commits are easier to review and revert. Write clear commit messages (present tense: "Add login form validation"). Use .gitignore to exclude node_modules, .env files, and build outputs.