1
Git and Version Control
Software Engineering
Version control records every change so a team can work together, review history and roll back. Git is distributed: every developer has the full history.
git init # new repository
git clone <url> # copy a remote repository
git status # what changed
git add . # stage changes
git commit -m "Add login page" # save a snapshot
git log --oneline # history
git branch feature-x # create a branch
git checkout -b feature-x # create and switch
git merge feature-x # merge into the current branch
git pull # fetch + merge from remote
git push origin main # upload commits
git revert <commit> # undo a commit with a new commit
merge keeps both histories with a merge commit; rebase replays your commits on top of another branch for a straight history.