Git
You might say
AI broke my code. I want to get back to the last version that worked.
Keep a history of code changes so work can be compared and restoredGit records snapshots of a project and lets people compare changes, create independent branches, and combine work. Each developer has a full local history. GitHub and similar services host repositories and collaboration, but they are not Git itself.
Anatomy
💻 Working tree Files you are editing
git add →
📥 Staging areaChanges selected for the next commit
git commit →
🗄 Local repository Your commit history
git push →
☁️ Remote repository GitHub
Files changed in your working tree that are not yet committed
git add stages selected changes for the next commit; it does not move the file itself.
git commit records the staged changes as a new commit in local history.
git push publishes local commits to a remote repository so collaborators can fetch them.
Typical use cases
Feature development
Bug fix
$ git log --oneline
c7d8e9f Fix mobile navigation alignment
a1b2c3d Build homepage layout
0f1e2d3 Initialize project
Each line shows a commit ID followed by its message
Team collaboration
$ git revert c7d8e9f
[main f4e5d6c] Revert "Fix mobile navigation alignment"
Creates a new commit that reverses the selected commit without deleting history
Release history
Further reading