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.
Know first
You can say this to an AI Agent
Before the large homepage change, inspect git status and the diff, confirm the current version works and contains no secrets, then create a clearly described commit as a restore point. Report its hash and any uncommitted files. Do not push or revert unrelated work.
When to use it
- Save meaningful code changesinit initializes the project→add selects changes→commit records a version
- Compare the current work with an earlier stateEach stable small step can be a commit.
- Develop separate ideas on branchesIf a change causes trouble, you can return to an earlier commit.
- Collaborate through a shared remote repository💻 Local repositorygit push →☁️ GitHub
When NOT to use it
- Commit passwords, tokens, or environment secretsWithout commits for a long time, it is hard to restore a stable version.
- Treat Git as a backup for generated files and large binaries● 111
● Made a few changes
● asdfThe message is unclear, making the version hard to identify later. - Combine unrelated changes in one unclear commit🗂my-first-page🗑 DeleteDeleting the project directory also loses local history.
- Run unfamiliar destructive commands without checking the target.envgit push →☁️The secret enters remote commit history.
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
Recommended tool
Web fine-tuning tool · Selector Pro
Select page elements for precise AI edits
Click a button, text, or card, note the change, then copy its exact location to AI.
Open Selector Pro website↗Further reading
Quick check