Hoc git branch

From openreachtech/hora-skills-ort-core · View interactive version

Hoc git branch is an AI agent skill from the GitHub repository openreachtech/hora-skills-ort-core. Conventions for the branches a repository carries — trunks, general branches, and the commits that open and merge them. Use before cutting a branch, merging one back, carrying a change onto one, or discarding one, and before the first edit or commit while `main`, `release/x.x.x`, `dev` or `env` is c

How to use this skill

Skill file

Git Branch

Conventions for the branches a repository carries — which one is a trunk, what a general

branch is called, the commit that opens a trunk and the commit that closes a sub-branch.

What belongs in a single commit, and how a subject is worded, are settled by the git commit

convention. The two commits described here are the exception it points at: their subjects are

specified in full below, because what they say is inseparable from what they are for.

No commit is made directly on `main`, `release/x.x.x`, `dev` or `env`

**A commit that carries a change of its own is never made while one of these four is checked

out, whatever the change is.** The only way a change reaches them is a branch merged back. The

two a trunk makes about itself carry none, and the bullet below names them. hotfix/xxxx is

not among the four; it is the one trunk worked on directly, as described under the trunk branch

below.

git branch --show-current. Where the answer is one of the four, cut a branch for the change

before touching a file, and commit there. Uncommitted edits travel with git switch -c, so

noticing late costs nothing as long as nothing has been committed yet.

There is no branch to work on, so the work does not start until one exists. A repository

whose branches are all trunks, or a checkout sitting on one with nothing else cut yet, is not

a case for committing there. The work always goes onto a newly created branch, and its

commits are made on that branch, with no exception.

"I will move it to a branch afterwards" — none of them makes a direct commit permissible, and

a commit that is going to be moved is still a commit made on the trunk.

the marker that opens it and the Merge … commit that brings a sub-branch in. Both are

described below.

Noticing late does not end the work at a report. Say which branch and which commits, then put

the line back: the commits are given a branch of their own, and the trunk returns to where it

stood.

```bash

git branch <branch> # the commits are held by a ref of their own

git rebase --onto origin/<trunk> @ # the trunk goes back

git switch <branch>

```

so the commits are held before the trunk is touched. Stopped after that one command, the

recovery has lost nothing and can be picked up again.

nothing is replayed and the branch simply arrives at <target>. Where a tracked file is

modified the rebase refuses and moves nothing, which is the whole of what separates it from

git reset --hard.

/hoc-git-prohibit-destructive-commands is the convention that bars it, and the stash below

is that convention's mechanism, borrowed here. What this one settles is the shape of the

recovery: which ref holds the commits, where the trunk returns to, and which branch the pop

happens on.

to the trunk, so they are set aside before the rebase and taken back after the switch:

```bash

git branch <branch>

git stash -u

git rebase --onto origin/<trunk> @

git switch <branch>

git stash pop

```

stops it, but all of them are part of the open work, and leaving any behind splits it

across two places.

changed the tree, the open edits may touch what they changed, and the rewound trunk no

longer carries any of it while <branch> still does. This is where the ordinary

stash-rebase-pop order does not reach: there the branch comes back to the work, and here

the trunk is moved away from it.

on the rewound trunk came back DU and kept the stash entry, while popping on <branch>

applied clean.

reflog answers the same question where the remote is not the reference.

trunk back then means rewriting published history, which is nobody's to do from here. Report

the branch and the commits, and ask for the trunk to be recovered before anything else is

taken up — /hoc-git-branch-remote settles what the trunk may do afterwards.

that lands on one cannot be taken back, and a change that skipped the branch skipped the one

step at which it could be read before it became part of the trunk.

Every rebase takes `-r`

**git rebase without -r (--rebase-merges) is forbidden. There is no ordinary case that

omits it.** Not preferred, not recommended where a branch has merges in it: the flag goes on

every invocation, and a command written without it is wrong whether or not this particular

branch happens to survive the omission.

git rebase -r <trunk> <branch>
git rebase -r --onto <trunk's new tip> <the commit this branch was cut from> <branch>

Without -r, git rebase drops every merge commit it replays. A branch that carried its own

sub-branches arrives flattened, and the --no-ff merges inside it are gone — the exact thing

--no-ff was used to keep. The loss is silent: the rebase reports success, the working tree

matches, and what is missing is structure no diff reports.

Whether the branch holds a merge commit right now is not the test. A branch with none loses

nothing today, but deciding case by case means re-examining the question at every rebase and

getting it wrong on the one branch that did carry a merge. The flag costs nothing when there is

nothing to preserve.

taken as such and said out loud. Nobody arrives there by default.

This rule stands ahead of everything below because the commands that need it appear throughout,

and because a rebase that drops a merge cannot be spotted afterwards from the result.

Editing a commit inside the branch takes `-i` as well

-r keeps the merges; -i is what opens the todo list. Given -r alone, a rebase runs the

sequencer but never presents a todo, so a sequence editor named in the environment is never

called — and the run reports every step successful while handing each commit back with the hash

it went in with.

git rebase -i -r --onto <base> <the commit the branch was cut from> <branch>

Measured on a branch carrying one merge: with -r alone the rebase printed eight steps and

Successfully rebased, and no hash changed. With -i -r the reword applied and the merge commit

survived, the graph keeping its shape.

and the message editor at scripts — one rewrites the todo, the other rewrites the message —

and nothing prompts. An interactive rebase can be driven rather than attended.

Cherry-picking its commits onto a fresh branch and amending the one that needed the new

subject reaches the same tree at the cost of the branch and every merge above it.

A rewritten trunk takes `--onto` as well

**git rebase -r <trunk> <branch> is right while the trunk only moves forward, and wrong once

the trunk has been rebuilt.** The two-argument form replays everything in <trunk>..<branch>,

and that range holds the branch's own commits only for as long as the commit the branch was cut

from is still on the trunk. Rebuild the trunk — rewind it and merge the sub-branches again — and

that commit is gone, so the range reaches back to whatever the two still share and sweeps up the

old trunk's merges on the way.

git rebase -r --onto <the trunk's new tip> <the commit this branch was cut from> <branch>

-r is what makes the damage silent. The flag exists to preserve merge commits, and it

preserves these too: the old trunk's Merge … commits are replayed inside the sub-branch, so the

graph comes out with two paths carrying the same subjects, and the branch appears to hold work

that was folded away. The rebase reports success and the tree is correct, which is why nothing

downstream catches it.

appearing twice is the whole of the symptom.

both times the two-argument form recreated its merges inside the sub-branch, and both times

--onto naming the commit the branch was cut from replayed only what the branch held.

A commit the base already holds is dropped, not resolved

**A rebase onto a base that has moved past the branch replays commits whose change is already

there**, and the ones that conflict are the safe half. A conflict stops and asks; a commit that

applies cleanly does not, and where the base holds the same change at a different place in the

file, what lands is the change twice.

Measured twice, on two branches against one base: a conflict was resolved by taking the base's

side, a later commit in the same rebase then applied without conflict at its own anchor, and both

times the result was a configuration file carrying the same key on two lines. Both times the tree

was correct at every other point, the rebase reported success, and nothing downstream refused it.

resolving them. A patch already upstream has nothing to contribute, so the resolution never

needed judgment in the first place.

leaves a commit in the branch claiming a change the base had already made, and the next rebase

of that branch makes the same duplicate again. Drop it with -i -r, which keeps the merges the

-i would otherwise cost.

something and the diff shows a line the base already had, the duplicate is what it is showing.

The trunk branch

A trunk branch is one that other branches are cut from and merged back into.

**Five are trunks by name, in every repository: main, and the four branches that may merge

into it.**

| branch | what it carries |

| :-- | :-- |

| main | the mainline every other branch descends from |

| release/x.x.x | one version's work, until it merges into main |

| hotfix/xxxx | one fix that cannot wait for a release |

| dev | long-lived integration. Legacy |

| env | the initial environment setup, and changes that leave the released artefact untouched |

Every other branch is a general branch, and takes the role rather than holding it. A

general branch behaves as a trunk for as long as work is split off it. The five above behave as

trunks whether anything is outstanding against them or not.

on it. A repository still carrying one holds it to every rule here.

it is decided by the kind of repository — see /hoc-git-branch-remote. **The set here is the

ceiling, not the instruction.**

The shape of the name settles nothing. release/x.x.x is a trunk and

retake/save-of-UserRepository is not, and the two are the same shape.

sub-branch of that trunk, and the trunk of what it carries. The role is held against a particular

branch, never held outright.

branch opens with the Start … marker described below; being a sub-branch, it merges back

into the trunk it was cut from once it is done. That the merge is made locally, with no pull

request to open early, takes nothing away from the marker.

The direction is the same at every level of the nesting.

directly: cut a branch for the change, commit it there, and merge it back. This holds for a

general branch from the moment it takes the role, and it holds on a trunk whose only commit so

far is its own opening marker — a trunk with nothing on it yet is still not a place to work.

the marker that opens it, and the Merge … commit that brings a sub-branch in. Both are

described below, and neither carries a change of its own.

sub-branch and no marker, and the branch merges into main as it stands.

would otherwise have carried it, and every step between the fix and main is time the

failure it fixes is still running. A sub-branch and its merge buy structure that nothing is

going to read on a branch holding one fix.

reaches main through a pull request like the rest, and it is deleted on merge.

trunk may be re-cut belong to /hoc-git-branch-remote.

how the structure described below gets cut at all. Nobody else is holding it, so nothing

disagrees.

What may be cut from `main`

Under Git flow, only a branch whose name is one of these is cut from main or origin/main:

| Kind of repository | Cut from main |

| :-- | :-- |

| boilerplate | release/x.x.x |

| npm package | release/x.x.x, env |

| application | release/x.x.x, env, hotfix/xxxx — and dev, in an older application only |

Every other branch is cut from one of these. **Where the one it needs does not exist yet, it is

opened first**, and its version is asked rather than assumed; no branch is cut from main in its

place.

The list repeats the table of /hoc-git-branch-remote, which stays its source, so that it stands

where a branch is cut and not a skill away.

A general branch taken straight off main has nowhere to land: the four are what main accepts, a

guard on main refuses the rest, and the branch arrives at a base it is not allowed to merge into.

Under GitHub Flow every branch is cut from main and returns to it, because there is no

other trunk to cut from. So one and the same branch is correct in one repository and stranded in

the other, and which it is cannot be read off the branch itself.

Ask which flow the repository is on before cutting a branch from main. Nothing announces

it: a repository that has not yet opened dev, env or a release looks exactly like one that

never will, and a wrong guess is not found until the pull request is refused. The tells are the

four names and a guard on main — where none of them is there, the repository is on GitHub

Flow, and cutting from main is what it wants.

this convention settles the answer itself, because the answer does not change between

repositories. Here it does, and the cost of assuming is a branch that has to be rebuilt.

When the structure is decided

Commit the work in one line first, and shape the branches once it is finished. The line is a

branch cut from the trunk for the purpose, never the trunk itself — a line committed onto

main, release/x.x.x, dev or env is the direct commit the first section forbids, and

cutting the markers afterwards cannot undo it. How many

sub-branches the work wants, and whether it wants a trunk at all, are answers the work itself

gives — and it cannot give them before it exists. A structure chosen in advance is a guess, and

a guess that turns out wrong costs a rebuild of everything already committed under it.

This is the opposite timing from granularity, which the git commit convention has decided

while working: by the time the tree holds six unrelated edits, the cheap moment for that one

has passed. Both rules say the same thing — decide at the point where the answer is knowable —

and the answers become knowable at different points.

So the order is: commit in a meaningful sequence until the work is ready for review, fold

together whatever turns out to be one decision after all, and only then cut the markers and

split the line into sub-branches.

finished line means returning to the trunk for each cut, not walking forward along the line as

the branches come off it. A branch cut while standing on the previous sub-branch carries that

branch's commits as well as its own, and the two arrive at the trunk stacked instead of side by

side — the second merge then reopens a line the first one closed.

was created from tells the two apart, and by the time the merges expose it the structure is

already built.

other reaches the trunk by its own pull request rather than by the local merge described

below. Sitting on it is how the prerequisite is had, and the reason the rule gives — a second

merge reopening a line the first one closed — does not reach the case, because the two never

merge into the trunk together. When the prerequisite lands, rebase the stack onto the trunk's

new tip and carry on.

history. Once the work has been pushed, the line stands as it is, and a structure it did not

get is a structure it does not get.

under a tag before anything moves, so that the original is one git switch away. The branch

is then reset to its base without touching the working tree, which turns the commits back into

a diff, and the pieces are committed afresh, each sub-branch cut from the trunk.

documentation fix that surfaces once the code and documentation sub-branches exist goes onto the

documentation sub-branch, as one more commit beneath its single merge. It does not go into the

code commit whose change left the document stale, and it does not open a second documentation

sub-branch beside the first.

consequence side by side, and it is the one ruled out: it carries a documentation edit into a

code sub-branch, which the ordering below keeps apart.

rewinding a trunk to insert one that was forgotten. A marker cannot be forgotten by a process

that ends with cutting it.

What the finished line is looked at for:

reaches the same pull request. A trunk earns its two extra commits — the marker and the merge

— by grouping several pieces of work, and there is nothing to group.

then restates the single commit beneath it, and the structure costs more commits than the work

contains. A trunk is worth its cost when a merge commit names something its commits do not say

individually.

trunk worth having is that at least one merge names a piece of work assembled from parts.

test and the implementation it checks, an export barrel and the test naming what it exports,

a registration removed and the file it pointed at rewritten. Neither commit says on its own

that the two are one piece, and neither says where the piece ends.

a summary it looks redundant over two commits whose subjects are already plain, and the

sub-branch is then given up for a cost it was not paying: the bullet above turns away a merge

that restates one commit, which a pair's merge does not do.

the work allows.** Its merge restates the one commit beneath it, which is the cost the bullet

above weighs against having a trunk at all; deciding for the trunk does not make that cost go

away for the sub-branch.

when, and when it folds back, belong to granularity.md of /hoc-git-commit.

sub-branch two is not a reason to cut a trunk; the bullets above settle whether there is one.

stands beside the others as work in its own right.** The bullets above settle the first. The

second asks whether the pieces are siblings — each a thing that was done, reviewable on its own

merit — or steps toward one thing they share. **Steps of one piece go in one sub-branch,

however much each carries.**

the other left. A fix to the code and the removal of the relaxation that fix made unnecessary

are not — the second exists only because the first happened.

classes, read as a pair of independent jobs. If neither of them alone clears the thing the

work set out to clear, they are halves of one job and belong on one branch.

test that a pair of one-commit steps passes and a pair of large steps fails.

a change introduces classes or members that did not exist and then adapts the existing code

to use them, the seam between the two is where the sub-branches part: one defines, one

adapts. The pair looks like steps of one piece — nothing uses the definitions until the

adoption lands — but only one half of the test holds. The definitions stand on their own:

they compile, they carry their own tests, and they could be taken while the adoption is left.

The adoption could not. That asymmetry is what the earlier examples lack, where neither half

means anything without the other.

that one new family can be used are three parts of one adoption, and they belong on one

sub-branch; splitting them by class produces siblings that are not siblings, which is the

failure the bullet above describes.

what it adopts.

Where every one of the commits was made for the sake of the sub-branches that follow, the pieces

are not siblings to be merged one by one or bundled in an octopus: they stack in one sub-branch

and merge once, and the merge says the shared reason in one sentence, as ## The merge commit

requires. A piece that takes more than one commit does not stack. Where even one of the

pieces is several commits, none of them is stacked, and each keeps a sub-branch of its own.

another — a workaround the class calls, a collaborator no other class uses — is not a sibling of

the classes around it. The two are gathered under a nested trunk named for the class they

serve, with the helper's sub-branch first and the served class's after it. Each keeps its own

sub-branch, so the trunk groups two pieces of work rather than folding them into one.

test above, and one of them is an artefact written for the first time while the rest change

what already stands, they do not sit side by side. The like ones gather under a nested trunk

of their own, and the levels then hold the two kinds apart.

and each still takes a sub-branch. What the difference of kind settles is the level one sits

at, which the sibling test does not reach.

Build name what did not exist before; Update, Retake and Fix name what did. A trunk

whose sub-branches take verbs from both sides is what this bullet turns away.

list of what the work did, and one mixing a thing that was made with three adjustments to

things that already stood gives the reader nothing to sort by. Gathered, the adjustments

arrive as one entry and the new thing stands beside it.

The order the sub-branches merge in

Merge the cheap ones first and the substantial ones last. Where one sub-branch changes a line

of configuration and another changes the code behind it, the line of configuration goes in first

and the code last. That is the order for a trunk that only groups pieces of work standing apart

from each other. A trunk named for one logical piece of work is ordered by what the work needs,

and the first bullet below sets that out.

The reason is what a diff from the newest commit holds. Commits run from the earliest at the

bottom to the latest on top. The sub-branch merged last is the largest, so a diff taken from the

newest commit is that branch's alone, with none of the small sub-branches' noise mixed in, and

checking it costs less. Merged earlier, the small ones sit beneath and stay out of that diff,

which costs little: the diff of a small commit is often what its message already says.

needs, and size does not enter.** Where the sub-branches are the steps of one resolution — the

declared dependencies raised, then the locked versions moved within their ranges, then what an

audit still reports overridden, then the install-script settings decided against the tree that

results — each step presupposes what the one before settled. The order of necessity is the order

the work is read in, and ranking by diff cuts it.

audit, is logical work and takes this order. A trunk that gathers pieces any of which could

be taken and the rest left follows the size order above.

order of necessity, so the merge list reproduces them, and a merge list that disagrees with

them is the one to suspect.

install-script entries merged first, ahead of the dependencies those entries are decided

against. Ordered by necessity, the same sub-branches read as the work does.

land goes last, and the entries decided against the settled tree are the plain case.

what gets checked, so the diff is what ranks the branches. A branch of four commits that raise

versions and regenerate a lock file is cheaper to read than one of two commits that change a

procedure.

commit, and git log --graph stacks their commits in the order the arguments are given — the

first argument at the bottom, the last on top, whatever the dates of the commits. The branch

with the fewest commits is the first argument and the one with the most is the last; branches

with the same count are ordered by diff, the smaller first. How the octopus merge is made is

under ## Merging back into a trunk.

octopus does not follow it there.

expensive work is rejected reaches the same order by another route, and it is not the reason.

several sub-branches each clear the way for one change to a file they share, that change is not

spread across them: it gathers into a sub-branch of its own, placed after them. A relaxation

removed only once every file it named has been fixed is the ordinary shape of this.

something a document states — a default, a return value, what is thrown — the document's

update exists only because the code moved. It is not placed in the sub-branch that moved it,

nor in that sub-branch's commit: it gathers into a documentation sub-branch of its own, merged

after the code sub-branches, however many of them moved what it states.

sub-branch of its own under a trunk for the environment.** A lint rule turned off for a file,

an entry in the spelling dictionary, an editor setting: whatever the tooling has to allow for

the new code to pass. Settings of different kinds are different pieces of work, not steps of one

— a linter's and a dictionary's are siblings — so each takes a sub-branch of its own, and the

group is gathered under a nested trunk named for the environment, merged ahead of the code it

serves. Where they are one commit each and were all made for the sake of what follows, the

stacking rule under ## When the structure is decided puts them in one sub-branch instead.

that differ in kind from the code and from each other, and bundled into one octopus merge

under the environment trunk they cost the reader a single line.

changes what the project depends on and regenerates the lock file; a setting changes how the

tooling reads the code. They are different pieces of work, and each answers to a different

rollback. The install is a sub-branch of its own, never one of the settings under the

environment trunk.

size.** The order by cost ranks pieces that have no bearing on one another. Where one piece

exists for the implementation — the packages its classes import — it is placed next to the

implementation, and nothing unrelated is put between them: a test double that only the suite

uses stands further back than the packages the classes depend on. A reader walking the merges

then meets the implementation straight after what it needs, rather than reading past a merge

that has nothing to do with either.

A feature trunk bundling the implementation of a family merges the branch carrying the Base~

class on its own, before any branch carrying a class derived from it.

the suite fails at that merge commit, because the class it extends is not on the trunk yet.

stand in parallel, and a Base~ class does not stand equal to the classes derived from it:

they are built on it. It is merged first, by itself, and the derived classes that remain,

independent of one another, may then go as an octopus on the tip that merge made.

first.

registers the classes of the family, so it depends on every one of them and has no meaning

without them. Merged as a sibling of the family at the top level, it stands apart from what it

registers; inside the family's trunk it comes after the last class and closes the trunk.

does not stand equal to what it declares.** Where one trunk gathers both the implementation of

a class family and such a module, the implementation branches are what the bundle holds, and

the declaring branch is not among them.

declaring branch on its own, onto the tip the octopus has just made.

depended on by nothing at run time, so it stands wherever it is put and no merge commit

fails. Where the rule above takes its answer from the suite, this one has only the reading.

for can both open with verbs for what did not exist before, so the difference of kind that

puts a level between siblings does not reach this. What parts them is that one is implemented

and the other describes it.

to the declarations — a global type, the type-level exports of the classes — is not folded

into the sub-branch of the class it describes. All of the work's type changes gather into one

independent sub-branch, merged last: after the implementation, and after the run-time export

of the same classes, which the type-level export mirrors.

substantial one goes first and the cheap ones follow it. The reason above does not reach that

case: a pull request is read on its own rather than as a diff from the newest commit, so there

is nothing for an earlier merge to be hidden beneath. What the order decides instead is which

piece of work the reviewer meets first, and that is the one the rest depends on.

takes one order merged locally and the other order opened as pull requests, so the question

to ask is how they reach the trunk — not how large they are, which is what both rules

measure once the route is known.

renamed underneath it. Measured on a branch whose base had renamed a file the branch edits: the

edit landed on the new name, every merge the branch held survived, and the tree came out

differing only by what the new base added. A conflict predicted there is not a reason to put a

branch anywhere but where its size says.

The same work across sibling repositories takes the same order

Where one piece of work lands in two repositories at once, the sub-branches under each trunk

are cut in the same sequence, so the two histories read alike. Put whatever is peculiar to one

repository first and whatever both share last: the shared part then sits at the same depth in

both, and a reader comparing them has the differences gathered at one end rather than

interleaved.

Where a repository has nothing to put in the position its sibling fills, it skips that position

rather than filling it with something else. A gap in one of two matching sequences still reads

as a match; a substitution does not.

Naming a general branch

A general branch is named <verb | category>/xxxx. Before the slash goes a verb for what the

branch does, or a category for what kind of work it is; after it, the name is free — an

identifier may appear verbatim.

declare/AlphaClass
define/sendMessage-of-AlphaClass
rename/FormElementClerk
fix/type-errors-reported-by-the-client-package
install/date-fns-4.1.0
tidyup/environment-files

The name is written for whoever scans git branch while the work is still in flight, so it

is deliberately descriptive. It outlasts the branch, too: the merge commit a host writes records

it, as Merge pull request #<number> from <owner>/<branch>, and that line is read in git log

long after the branch is deleted.

class and Define names a member, a function or a constant, which is why

declare/AlphaClass and define/sendMessage-of-AlphaClass say what they carry without any

further explanation. The verbs are listed in the git commit convention.

tidyup/xxxx.

is left spells the relation out instead of punctuating it.

package's own version is done once per release, so a label naming only the thing touched

returns, unchanged, for every release, and the merge commits it leaves in the history read

alike. The version, or the package and its version, goes into the label, as install/date-fns-4.1.0

already does.

```

Bad update/package-version

Good update/package-version-0.2.0

```

label is missing the value that would stop it.

is, where a connector joins two things the branch carries, which the rule on altitude below

turns away.

abstraction** — implement/xxx, setup/xxx, feature/xxx, retake/xxx, update/xxx. A

branch that is about to have six branches cut from it cannot be named for one narrow verb

without lying about five of them.

branch opened for one tidy-up that has grown into the implementation of a whole mechanism still

says tidyup/xxxx, and the name is now a claim about the work that is false. git branch -m

brings it to the altitude of the work, the one its opening marker is written at, and the label

and the marker then say the same thing.

nesting adds no constraint of its own: <verb | category>/xxxx, free. The narrow verbs

belong here, where each branch really does carry one thing.

same work, and the shorter one is what a reader scanning git branch gets through faster.

What comes after the slash is a label, not a sentence.

branch holding two changes is still one branch, and a connector in the label hands the reader

the division before the thing. Where several changes land on one thing, the label is that thing

and the changes are what the commits are for. That a text never enumerates, whatever the

connector, belongs to /hoc-notation; this is the one place the rule bites for the reader

scanning git branch.

```

Bad add/retry-and-timeout-options-to-AlphaClient

Good update/AlphaClient

```

The altitude to find is the one the changes sit beneath, and it is usually already named —

the class, the module, the document they all touch. A label that reaches for a connector is one

written before that name was looked for.

The branch-opening marker commit

A branch that will act as a trunk opens with an empty commit whose subject begins with

Start — or with Release, on a release/x.x.x trunk. This is a deliberate convention, not a

checkpoint or a placeholder.

# opening a long-lived dev branch
git switch -c dev
git commit --allow-empty -m 'Start dev'

# opening a general branch that will carry sub-branches
git switch -c feature/equip-tools-for-each-application
git commit --allow-empty -m 'Start adding the skills installer'

# opening a nested trunk: cut from the branch above, and carrying sub-branches of its own
git switch -c update/domains-a-repository-selects
git commit --allow-empty -m 'Start updating the domains a repository selects'

work on it yet, so there is nothing for it to carry. A Start … subject on a commit that

actually contains changes is not this convention — it is a mislabelled change.

branches be cut from this one and merged back into it? Where the answer is yes, the branch is

a trunk — that is what this document defines the word to mean, and that definition is the

whole of the condition.

from it, so there is nothing for a marker to open. A branch whose first commit is the fix

needs no commit placed ahead of the work, because the work is already there.

work split off it is a sub-branch and a trunk at once, and it is the trunk half the marker

answers to. Such a branch merges back locally, with no pull request anywhere in it, and it

still opens with Start ….

host, the marker buys a branch that can be reviewed before any code exists — but that is

something the commit makes possible, never the test for making one.

nothing left to open.

of work, so a marker listing what the branch will carry fails the same way a label does, and

the two then disagree besides.

carries without stretching, the branch is what is wrong — not the subject. A marker reading

Start implementing the validator family over a branch that also rewrites the engine using it

is not a marker that needs rewording; it is a branch carrying two pieces of work, and the

second belongs beside it rather than under it. Writing the marker is therefore the moment the

contents get checked, which is one more reason it is cut while the structure is being shaped

rather than at the start.

were settled one commit at a time, by what each commit did, so they are the record of what the

branch holds; the marker's verb is chosen once, for the whole, and nothing else reads the two

side by side. Where a sub-branch opens with a verb the marker's verb cannot speak for, that

sub-branch is the second piece of work the bullet above describes.

it: an update of things that already exist takes Add, Kick out and Fulfill as parts of

itself. The question is whether the marker's verb still names what each of them did.

what that meaning reaches: Start updating the skills cannot speak for an Author commit,

because an update carries forward what was already there. **Enhance and Implement are

kept out of that table for this reason** — each names a whole piece of work rather than what

one commit did, so a thing written for the first time is part of one. The git commit

convention says why they are kept out.

whose commits opened with Author: a skill written for the first time, which no update of

the existing skills covers. The issue written at the trunk's altitude inherited the marker and

took the new skill in under it, so the mismatch outlived the branch. The marker's verb was

updating, and that is where it failed: Start enhancing the skills would have held the

same sub-branch.

placeholder word.

Start <verb>ing xxxx — the verb in its -ing form, then what it acts on.

```

Start adding the skills installer

Start renaming kit/skills/_core/ to core/

Start updating the domains a repository selects

```

A later reader scanning the log gets the branch's purpose for free.

environment, Start setting up the environment. It is a trunk by name like dev`, and

unlike dev the name says nothing about which environment work is being opened.

names the branch and stops there, and Start provisioning env puts the branch back into

the slot the work belongs in. Either way a reader scanning the log learns only which

branch they are on, which the ref beside the subject has already told them.

Start does not appear, because the version is the whole of what is being started.

migrating the mail templates from sample-app`. Stated once here, it covers every

commit on the branch, and the merge commit keeps it in the history after the branch is gone.

of /hoc-git-commit.

The merge commit

A branch merges back into its trunk with --no-ff, and the merge commit that results carries a

subject of its own.

Merge the classes of the skills installer
Merge the core/ rename in the repository documents

git log --graph already shows, and the branch is deleted moments later. What it carried is

the part that has to survive it.

sub-branch under a trunk is the thing that sentence says, so a subject needing and, or any

connector that lists what the branch carried, describes two sub-branches written as one, and

the branch is split until each has a sentence of its own. The commits that one sentence covers

stand in one sub-branch and merge once. That a text never enumerates, whatever the connector,

belongs to /hoc-notation; this is where the rule bites for a merge subject.

request is described for free — Merge pull request #53 from …. A merge made locally has no

such author, and this subject fills the gap.

/hoc-git-commit.

chooses its wording.

Merging back into a trunk

/hoc-git-branch-remote. What follows is how a branch merges back locally, into any other

branch acting as a trunk.

at: the branch's commits are strung onto the trunk's line, and the fact that they arrived

together, as one piece of work, stops being visible at all.

work when a fast-forward is what would otherwise have happened. On a branch that has fallen

behind the tip, git makes a three-way merge regardless, and the flag changes nothing.

```bash

git merge-base --is-ancestor <trunk> <branch> # must succeed

```

Failure means the branch has not been rebased onto the current tip. Rebase it, then merge.

merge has two parents as well, and nothing in the finished history separates the two. That

is why this is checked before the merge, and cannot be checked after it.

takes pull requests on the host, the local ref is only as new as the last time it was moved,

and a merge landed there on the host is not in it. The check then passes against a tip the

remote has left behind, the merge lands on that stale tip, and the trunk no longer

fast-forwards to what the remote holds. So fetch first, and advance a trunk that is behind

before checking anything — standing on the branch, since the refspec will not move the ref

that is checked out:

```bash

git fetch origin <trunk>:<trunk>

git rebase -r <trunk> <branch>

git merge-base --is-ancestor <trunk> <branch>

```

Measured: a local release trunk stood one pull request behind its remote, and a branch cut

from it passed the ancestry check against the local ref. Only a comparison with the

remote-tracking ref showed that a pull request had already merged there.

tip.** The commits inside a branch may stand red on purpose, as /hoc-git-commit-order lays

out; the branch as a whole may not, at the point it goes back. Run the suite after the rebase

above, on the tip that will merge — see /hoc-workflows.

flight, and that reader is gone. This includes a trunk that merges into another trunk —

release/x.x.x, hotfix/xxxx, dev and env are all deleted once they land on main.

A sub-branch that was given one is refused although the trunk in front of you holds every

commit it carries:

```

warning: not deleting branch 'add/xxxx' that is not yet merged to

'refs/remotes/origin/release/x.x.x', even though it is merged to HEAD

error: the branch 'add/xxxx' is not fully merged

```

Unset the upstream and delete again:

```bash

git branch --unset-upstream <branch>

git branch -d <branch>

```

-D is not the answer to this. It deletes whatever it is given, so it removes the check

rather than the cause — and on the one branch where the check was right, nothing is left to

say so.

one and git switch -c <name> <trunk> does not, so a branch cut from a remote-tracking ref

carries a tie to that ref for the rest of its life. The refusal above is usually the first

time anybody meets it.

everything cut from it afterwards inherits that. Merging origin/main back in would

settle it, but re-cutting the branch settles the same thing without leaving a merge commit

that carries no work of its own:

```bash

git branch -d dev

git switch -C dev origin/main

```

the remote held when it was last fetched, and nothing refreshes it on its own. Cut from a

stale one and the trunk stands at a commit the remote has left behind — silently, because

every branch cut from it afterwards inherits that base and the first report of it is the size

of a pull request's diff.

```bash

git fetch origin

git switch -C dev origin/main

```

**Cutting from a local branch does not need the fetch, and does not get the guarantee

either**: a local trunk is as old as the last time somebody moved it.

Naming the branch on both sides of the colon moves the local ref to what the remote holds,

and the form refuses anything that is not a fast-forward — so the one operation these

branches must never take is not available to it.

```bash

git fetch origin <trunk>:<trunk>

```

Standing on another branch while it runs is the point: nothing is checked out, nothing is

merged, and a trunk that has diverged comes back refused rather than silently rebuilt.

the trunk's new tip, merge it, rebase the one after that.** Every merge moves the tip, so each

branch is rebased against a commit that did not exist while the branch before it was still

open. Each then merges into the trunk as it now stands, rather than reopening a line that was

already closed.

```bash

git switch <trunk>

git merge --no-ff <first> -m 'Merge …'

git rebase -r <trunk> <second> # onto the tip the merge above just made

git switch <trunk>

git merge --no-ff <second> -m 'Merge …'

git rebase -r <trunk> <third> # onto the tip that merge made

git switch <trunk>

git merge --no-ff <third> -m 'Merge …'

```

branches were cut from, or anywhere else — settles nothing past the first merge: the second

branch is behind the tip again by the time its turn comes. The commit each rebase needs does

not exist until the merge before it is made.

rebase drops a commit whose change the trunk already holds, and where that was the branch's

only commit the branch arrives at the trunk's own tip. The --no-ff merge that follows then

prints Already up to date., exits zero, creates nothing, and **a rung of the structure is

gone** — leaving a graph that reads as one which was never meant to have it.

```bash

git rebase -r <trunk> <branch>

git rev-list --count <trunk>..<branch> # must be greater than zero

```

Measured before it and after it is not the same measurement. Before the rebase the count

was one and would have passed; the rebase took it to zero. The only warning git gave was a

hint about skipped cherry-picks, which -q and a trailing tail both remove.

branch left behind the tip fails --is-ancestor and still makes a merge commit, because

it holds commits of its own. A branch sitting exactly on the tip passes

--is-ancestor — it is not behind anything — and makes none.

already, so the structure was drawn with one rung too many, or the change belongs to a

different sub-branch than the one that carried it. Both are decisions, not repairs.

success without committing — a cherry-pick refused for a bad flag, a patch that did not

apply, a copied file identical to the one already there. The check does not care which.

is asked for, it is the shape to make, and the cycle is not offered as another reading of the

request.

```bash

git switch <trunk>

git merge --no-ff -m 'Merge …' <merged first> <merged next> <merged last>

```

another, and of one kind. Where several such branches would otherwise be merged one by one,

the octopus is the shape to take, and it shortens the graph. Pieces that are one commit each

and share a reason need neither: they stack in one sub-branch, as `## When the structure is

decided` says. Branches with a dependency between them — one built on another, one that others stand

on — merge one by one, in the order of the dependency.

merges, so no rebase happens in the middle — but each branch is checked against the tip

first, with --is-ancestor and with a count above zero, exactly as in the cycle.

equal counts, as ### The order the sub-branches merge in says. The first argument sits at

the bottom of the graph and the last on top, and the legs run left to right in the same

order.

since one commit now stands for every branch it received.

Carrying a change onto a branch by hand

**A rebase moves a change between branches and keeps a record of what it moved. Writing a file

does neither.** Where an edit was made against one base and is then written onto a branch that

carries its own commits on the same file, whatever those commits added is reverted — and the

revert appears in no diff of its own, because the file simply arrives as the edit left it.

Measured: a file edited against a trunk was about to be written onto a branch carrying six commits

on that same file. Written whole, all six would have been undone, and the commit doing it would

have read as an ordinary update.

So the first act is to read what is already there. Not the file — the two of them against each

other:

git diff <the branch> -- <the path>          # what the branch has that the base does not

and the reverse. A run of differing lines says the two disagree; a list of section names says

where and why, and it is short enough to check by eye.

branch's version everywhere else. What comes out is the branch's work with the edit laid over

it, which is what writing the file whole was supposed to produce and does not.

absent from the edit is the branch's own work, and dropping it is the same overwrite arriving by

omission rather than by replacement.

Confirm afterwards by naming what should have survived. The edit's own additions are easy to

see because they are what was just written; the branch's are the ones a wrong application

removes, so those are the ones to look for by name.

What a branch still carries

Whether a branch's work has reached a trunk is not answered by ancestry. --is-ancestor

answers whether the trunk holds those commits, and a branch whose content arrived by another

route — cherry-picked, rewritten, or done again on a different branch — fails that test while

holding nothing the trunk lacks. Measured: a branch reported as not merged turned out to carry no

change the target did not already have.

Three tests answer three different questions, and none of them stands in for another.

| Test | What it answers |

| :-- | :-- |

| git merge-base --is-ancestor <target> <branch> | Whether the trunk holds these very commits |

| git cherry -v <target> <branch> | Which of the branch's patches the target already holds |

| A rebase onto the target | What the branch would actually add |

never appear in its output and a clean run of - is a statement about the non-merge commits

alone.

against its own base, so a commit written on an older base comes out + although the file it

produces is identical to the target's. Measured: two commits marked + left no content

difference at all against the target.

and nothing else. Measured on two branches: one of twenty-five commits came out holding three

that carried no change, and one of twenty-one came out holding a single commit.

target shows what the two differ by, not what the branch contributed: where the target has

moved on, the branch appears to hold work it never touched. Measured: the files filling such a

diff had never been edited on the branch at all.

Deciding a branch may go

**What decides it is what the branch uniquely holds — never its age, its name or how long it has

been open.** Run the tests above, then look at what would be lost with the ref:

empty, nothing is lost by deleting it.

carries nothing itself.

ref rather than with the commits.

branch with nothing to close.

has been rebased onto something that does.

Where all of these come back empty, the branch is a copy of work that is already elsewhere, and

keeping it costs a reader the time it takes to establish that again.

that it might be useful later is answered by how small the change was: writing it again costs

less than rebasing a stale branch onto a base that has moved.

reaching for -D. The refusal is the check described above doing its work.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.