Day-2 Git with Grok
You shipped something. Now save it with git—safely—with Grok as a helper, not the boss of your history.
Git is a save system for code. Grok can run git commands and draft commit messages. You decide what gets recorded forever—especially force pushes, history rewrites, and commits of secrets.
Why “day 2”?
Day 1 was shipping something that runs. Day 2 is not becoming a git expert. It is learning enough to:
- See what changed (
status,diff) - Save a checkpoint you could return to (
commit) - Stop Grok from “helpfully” rewriting history or committing junk
If you have never installed git, do that first on your machine, then come back. This lesson assumes git --version works in a terminal.
Words you need (plain English)
| Word | Meaning |
|---|---|
| Repository (repo) | A project folder where git is tracking history |
| Commit | A saved snapshot with a short message (“what changed and why”) |
| Status | Which files are new, changed, or staged |
| Diff | The line-by-line change since the last commit |
| Stage | Mark which changes go into the next commit |
| Branch | A named line of work (start with main only) |
Who decides what (Grok vs you)
Usually fine for Grok (with you watching)
git status,git diff,git log -5- Draft a commit message from the diff
- Stage specific files you named
- Create a commit after you approve the message and file list
Human decides (or forbid by default)
- Force push, hard reset, history rewrite
- Commit of
.env, keys, passwords, huge binaries - “Clean” the repo by deleting untracked work you still need
- Pushing to a shared remote without your OK
Stay on Ask permission mode while learning git. If Grok wants a destructive command, deny it and say: “Only status, diff, and a normal commit—no force or reset.”
“Fix the repo however you want—use force push if needed.”
“Run git status and git diff. Summarize changes. Propose a commit message. Do not commit until I say yes. Never force push or reset.”
Status & diff (your daily loop)
Before any commit—yours or Grok’s—run the same two checks:
- Status — what is dirty?
git status - Diff — what actually changed?
git diff git diff --staged
Ask Grok to explain the diff in plain English, then skim the real lines yourself for secrets and accidental files.
If the diff shows API keys, tokens, or passwords, do not commit. Remove them from the files, add the secret path to .gitignore, and rotate the key if it already leaked into chat history or a remote.
Commit habits that keep you safe
- Small commits — one idea per commit when you can (e.g. “Add restart button”, not “misc fixes”).
- You own the message — Grok drafts; you edit. Prefer present tense: “Add win screen” over “Fixed stuff”.
- Stage intentionally — prefer naming files over blind
git add .until you trust the tree.git add index.html css/style.css js/main.js git commit -m "Add restart button and win message" - Verify —
git statusshould be clean (or only show work you left out on purpose).
Goal: Help me prepare a safe git commit. Do not commit yet.
1. Run git status and git diff in this project.
2. List files that should and should not be committed.
3. Draft a one-line commit message.
4. Stop and wait for my yes/no before any git add or git commit.
5. Never use force, reset --hard, or push unless I explicitly ask.Lab
Use the project from your ship walkthrough (or any practice folder with a few changed files).
- In a terminal,
cdinto the project. If git is not initialized yet:git init git status - Start Grok in that folder. Stay on Ask mode.
- Send the “Goal: Help me prepare a safe git commit…” prompt above (copy the whole box).
- Read Grok’s summary. Open the real
git diffyourself. Confirm no secrets. - If the draft message is good, reply: “Yes—stage only these files: …” and list them. Approve the commit command when Grok proposes it. If anything looks wrong, say “No commit. Stop.”
- Run
git log -1 --onelineand confirm the snapshot is yours.
You can explain status vs diff in one sentence each; you have either made a reviewed commit with Grok’s help or deliberately stopped before a bad commit; and you know three git actions you will not let Grok do alone (force push, hard reset, commit of secrets).
Quick check
Next in the path: Intermediate daily habits—start with Slash Commands if you have not already.