Document that add writes to the remote, and add --no-push#37
Conversation
Creating a new branch with `git trees add` always finishes by calling `track`, which runs `git push -u origin HEAD` when the branch is absent on the remote. A local-feeling command therefore performs a network write and creates a public branch, with no prompt and no mention in the docs. Pushing to a shared repo can fire CI, send notifications, or publish a branch name that leaks a customer or an embargo, and anyone without push rights just gets a confusing failure. The default is right for the tool's stated use case — parallel coding agents need an upstream — so it stays. What changes is that it is now stated plainly in the README under both `add` and `track`, and it can be turned off: - `--no-push` on `add` and `track`: sets the upstream when `origin/<branch>` exists, otherwise leaves it unset and prints the exact `git push -u origin HEAD` to run. Exit status stays 0 — not setting an upstream is the requested outcome, not a failure. - `TREES_NO_PUSH`, any non-empty value, for setups that want it off globally. No prompt: that would break the non-interactive agent workflow this tool is for. `cmd_track` now parses options rather than taking a bare positional, so `track [path] [--no-push]` works in either order and rejects unknown options. CI covers both paths plus the env var. Closes #25. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Review question on this PR: is there a way to set the tracking branch? There isn't — `cmd_track` hardcodes `origin/$br`, same remote and same name, and nothing exposes an arbitrary upstream. That is a deliberate consequence of the layout assuming one remote, not an oversight, so it belongs in the contributor constraints rather than the README. Noted along with the trap for anyone adding `--upstream` later: `add` calls `cmd_track` unconditionally, so a flag that isn't threaded through `cmd_add` would silently overwrite the caller's choice. No behavior change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
No. Per your call, no code or README change; recorded in Worth noting the escape hatch already works — |
Merge order: 3 of 6, into
v1.0.0-integration.Closes #25.
The problem
git trees addalways finishes by callingtrack, which runsgit push -u origin HEADwhen the branch is absent on the remote. Alocal-feeling command therefore performs a network write and creates a public
branch, with no prompt and no mention in the docs.
The README documented the failure case ("if that push/upstream setup fails,
addexits nonzero") but never the success case. Pushing to a shared repo canfire CI, send notifications, or publish a branch name that leaks a customer or an
embargo. Anyone without push rights just gets a confusing failure.
What changed
The default stays — parallel coding agents need an upstream, which is the whole
point. What changes is that it is stated, and it can be turned off.
Docs. The
addsection now leads with a callout thataddwrites to theremote and what that costs;
tracksays the same; the Environment table gainsTREES_NO_PUSH;usagegains a note.--no-pushonaddandtrack. Sets the upstream whenorigin/<branch>already exists; otherwise leaves it unset and prints the exact command to run.
Exit status stays 0 — not setting an upstream is the requested outcome, not a
failure. This matters because
cmd_addcallscmd_track "$dir" >&2 || return 1,so a nonzero return would fail the whole
add.TREES_NO_PUSH, any non-empty value, for setups that want it off globally.No prompt — that would break the non-interactive agent workflow this tool exists
for.
cmd_tracknow parses options instead of taking a bare positional, sotrack [path] [--no-push]works in either order and rejects unknown options andextra arguments.
Verified
bash -nandshellcheck -s bashclean. Against afile://fixture:add nopush --no-push, remote branch absentorigin/nopushnot created, upstream unset, push command printed, exit 0add already-there --no-push, remote branch presentorigin/already-thereTREES_NO_PUSH=1 add envnporigin/envnpnot created, exit 0add feature-x/add brandnew, no flagorigin/feature-x/origin/brandnew;origin/brandnewis created — default unchangedtrack nopush --no-push,track --no-push nopush2track --bogus,track a badd pp --no-push --print-pathFull smoke block run locally end to end.
Conflicts to expect
cmd_add's option loop is adjacent to #36's branch-name validation (differenthunks — should merge clean). The README
add/tracksections are separate from#38's quickstart and install edits, but #38 adds a Prerequisites section that
mentions forge auth for pushing; land that line once, in whichever merges second.
🤖 Generated with Claude Code