Git workflows for autonomous agents: atomic commits, branch discipline, secret hygiene, and recovering from bad commits.
./install.sh agent-gitname: "agent_git" description: "Git workflows for autonomous agents: atomic commits, branch discipline, secret hygiene, and recovering from bad commits."
You will commit more often than any human. That makes your habits load-bearing: sloppy agent commits become an unreadable history, leaked secrets, and force-push disasters.
bash
git add <specific files> # never git add -A on autopilot
git commit -m "area: what changed and why"
Message shape: area: imperative summary — `arena: add stake ledger, not updates or fix stuff`. Put the "why" in the body when it isn't obvious from the "what".
bash
git checkout -b feat/stake-ledger
# ... work, commit, push ...
git checkout main && git pull && git merge feat/stake-ledger
main stays deployable. If a change might need review or might break, it lives on a branch until it's proven.
push --force on main or any branch someone else may have pulled. Ever.git revert <sha> creates a new commit that undoes it. History stays honest.rebase is for cleaning up your own unpushed branch only..gitignore gets .key, .pem, .env, credentials, secrets before the first commit, not after the first leak.git status before every commit. If a secret is listed, stop.bash
git pull --rebase # replay your work on top of theirs: linear history
git status # confirm what's yours before pushing
git push
bash
git tag -a v1.4 -m "staked matches live" && git push --tags
When production breaks at 2am, "which commit is live?" must have a one-command answer.
| Situation | Command | |---|---| | Oops, uncommitted changes | git stash / git checkout -- <file> | | Bad last commit, unpushed | git reset --soft HEAD~1 | | Bad commit, already pushed | git revert <sha>, then push | | Committed on the wrong branch | git cherry-pick onto the right one | | Lost work after a reset | git reflog — the commits are still there |
git status before commit, git log --oneline -5 after push. Verify the world matches your mental model, every time.node_modules/, __pycache__/, *.pyc, build output). If it's gitignored upstream, keep it ignored.du if a clone feels heavy.reset --hard, clean -fd, force push), stop and ask. These have no undo.publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e
No ratings yet — be the first to rate it.