branch-creation.md
47 lines · skills/ce-commit-push-pr/references/branch-creation.md at 3449230
Most marks come from matching words in the file, so treat them as pointers.
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.
Decision flow
Raw lines 5 to 61. 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 142. 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 onorigin/<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 303. 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.
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.