docs(advanced-git): two measured git behaviours promoted from agent memory - #339
Conversation
|
Warning Review limit reachedNext included review available in 51 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c461cfb to
7242fa8
Compare
"Leave the worktree before you remove it" credits the missing `--force` with catching an unintended removal. That guard only covers tracked files. Everything `.gitignore` matches goes with the directory: build output, caches, a local `.env`, whatever a job wrote there. Those are the files that exist in no other copy, and nothing in git can recover them because they were never in the object store. Measured on git 2.55.0: a worktree holding an ignored `.env` and an ignored `build/out.txt` was removed by a plain `git worktree remove` -- exit 0, no warning, both files gone. Adds the `status --porcelain --ignored` read that shows what would be lost. Assisted-by: claude-code:claude-opus-5 Agent-Session: https://claude.ai/code/session_01NxSeVq1hDnGBCqKLGcjQ6m Agent-Host: 32116e Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
…-force-with-lease `git clone --bare` leaves `remote.origin.fetch` empty, so the clone creates no `refs/remotes/*`. The lease then has no recorded remote state to compare against and the push is rejected with `(stale info)`. The message reads as "somebody else pushed", which is the trap: nobody did, and the reflex it invites is plain `--force`, dropping the protection entirely. Both remedies measured on git 2.55.0 -- passing the lease its value from `git ls-remote`, and repairing the clone once by setting the refspec and fetching. The second is what a long-lived bare layout wants: with no refspec `git fetch origin` updates nothing, so every later "is my branch behind?" question is answered from refs that never move. Recorded here rather than under Shallow Fetches: a `--depth 1` clone does carry `refs/remotes/origin/*` and pushes with an ordinary `--force-with-lease` without complaint, so depth is not the condition -- the missing refspec is. Assisted-by: claude-code:claude-opus-5 Agent-Session: https://claude.ai/code/session_01NxSeVq1hDnGBCqKLGcjQ6m Agent-Host: 32116e Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
7242fa8 to
8c86328
Compare
Review of this PRCopilot was unavailable — the account's review quota is exhausted, so the Both claims in this diff were measured before being written, not recalled. That was the point of the exercise, and it changed one of them.
The Scope. One file, 44 added lines, nothing removed. No Verification. Assisted by claude-code:claude-opus-5 — Session |
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
Self-review: 8c86328 The review this pull request demands is unsatisfiable (Copilot quota wall or repeated bot failures on this head). Per the documented fallback, the diff on this head was reviewed by the PR author; this comment is the on-the-record attestation the merge gate reads back. It stops matching on the next push. |



Merging this records two git behaviours that cost data or invite a wrong fix, both measured on git 2.55.0 rather than recalled:
git worktree removedeletes ignored files without asking, and a bare clone's missing fetch refspec makes--force-with-leasereject with(stale info). Both sit next to the section they correct; nothing is removed.These come from a
/retro promotepass over accumulated local agent memory. Nineteen candidates in the git area were checked against every reference on currentmain. Most did not belong here: five describe one operator's environment and identities, one is about the agent harness rather than git, one is a SonarCloud/Pages decision, and one is already in the GitLab skill's cheatsheet. Two were verified as already covered —advanced-git.md:1638for never runninggit checkout <ref> -- <path>over an uncommitted change, andadvanced-git.md:1876for staging by name instead ofgit add -A.The two changes, one commit each.
advanced-git.md, "Leave the worktree before you remove it" — the section credits the missing--forcewith catching an unintended removal. That guard only covers tracked files. A worktree holding an ignored.envand an ignoredbuild/out.txtwas removed by a plaingit worktree remove: exit 0, no warning, both files gone. Those are the files that exist in no other copy, and nothing in git can recover them because they were never in the object store. Adds thestatus --porcelain --ignoredread that shows what would be lost.advanced-git.md, "Bare-Repo Layouts" —git clone --bareleavesremote.origin.fetchempty, so the clone creates norefs/remotes/*and the lease has no recorded remote state to compare against. The push is rejected with(stale info), which reads as "somebody else pushed" and invites plain--force, dropping the protection entirely. Records both remedies, each measured: passing the lease its value fromgit ls-remote, and repairing the clone once by setting the refspec and fetching. The second is what a long-lived bare layout wants — with no refspec,git fetch originupdates nothing, so every later "is my branch behind?" question is answered from refs that never move.On where the second one sits. The note this came from blamed
--depth 1, and that is wrong: a shallow clone does carryrefs/remotes/origin/*and pushes with an ordinary--force-with-leasewithout complaint. Measured both before writing, which is why this landed under Bare-Repo Layouts rather than under Shallow Fetches.Verification.
validate-skill.shreports 0 errors and 20 warnings both on this branch and on unmodifiedmain— identical.Assisted by claude-code:claude-opus-5 — Session
https://claude.ai/code/session_01NxSeVq1hDnGBCqKLGcjQ6m