Skill Tracer
Skills › Compound Engineering › ce-commit-push-pr › branch-creation.md

branch-creation.md

47 lines · skills/ce-commit-push-pr/references/branch-creation.md at 3449230

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Branch creation from default branch
2
3Local `<base>` may have stale commits (another session/worktree advanced it) or commits the user authored intending to branch from later. Local git can't distinguish these — ask when unpushed commits are present.
4

Branch creation from default branch

Local <base> may have stale commits (another session/worktree advanced it) or commits the user authored intending to branch from later. Local git can't distinguish these — ask when unpushed commits are present.

Raw lines 1 to 4
5## Decision flow
6

Decision flow

Raw lines 5 to 6
7### 1. Fetch fresh remote base
8
9```bash
10git fetch --no-tags origin <base>
11```
13If fetch fails (network, auth, no remote), use the fallback at the bottom.

1. Fetch fresh remote base

git fetch --no-tags origin <base>

If fetch fails (network, auth, no remote), use the fallback at the bottom.

Raw lines 7 to 14
15### 2. Check for unpushed local commits on `<base>`
17```bash
18git log origin/<base>..HEAD --oneline
19```
21- **Empty output:** set `BASE_REF=origin/<base>` and proceed to step 3.
22- **Non-empty output:** show the commit list and ask (per the "Asking the user" convention in `SKILL.md`):
24 > "Local `<base>` has N unpushed commits not on `origin/<base>`. Carry them onto the new feature branch, or leave them on local `<base>`?"
26 - **Carry forward** → `BASE_REF=HEAD`. The new branch starts from local HEAD, preserving the commits.
27 - **Leave on `<base>`** → `BASE_REF=origin/<base>`. The new branch starts clean; commits remain on local `<base>`.
29 Never default silently — carrying foreign commits into a PR is worse than asking again.

2. Check for unpushed local commits on <base>

git log origin/<base>..HEAD --oneline
  • Empty output: set BASE_REF=origin/<base> and proceed to step 3.
  • Non-empty output: show the commit list and ask (per the "Asking the user" convention in SKILL.md):
"Local <base> has N unpushed commits not on origin/<base>. Carry them onto the new feature branch, or leave them on local <base>?"
  • Carry forward → BASE_REF=HEAD. The new branch starts from local HEAD, preserving the commits.
  • **Leave on <base>** → BASE_REF=origin/<base>. The new branch starts clean; commits remain on local <base>.

Never default silently — carrying foreign commits into a PR is worse than asking again.

Raw lines 15 to 30
31### 3. Create the feature branch
33```bash
34git checkout --no-overwrite-ignore -b <branch-name> "$BASE_REF"
35```
37If checkout fails because uncommitted or ignored files would be overwritten, stop and ask the user to handle the colliding paths. In `mode:pipeline`, report the blocker without asking. Do not stash or remove the colliding paths.

3. Create the feature branch

git checkout --no-overwrite-ignore -b <branch-name> "$BASE_REF"

If checkout fails because uncommitted or ignored files would be overwritten, stop and ask the user to handle the colliding paths. In mode:pipeline, report the blocker without asking. Do not stash or remove the colliding paths.

Raw lines 31 to 38
Involves a person stop and ask :37
39## Fetch failure fallback
41If `git fetch` fails, branch from current local HEAD:
43```bash
44git checkout -b <branch-name>
45```
47Note in the user-facing summary that base freshness was not verified. Skip the unpushed-commits check — without a fresh `origin/<base>`, the answer is unreliable.

Fetch failure fallback

If git fetch fails, branch from current local HEAD:

git checkout -b <branch-name>

Note in the user-facing summary that base freshness was not verified. Skip the unpushed-commits check — without a fresh origin/<base>, the answer is unreliable.

Raw lines 39 to 47