Agentic Research

Branch

Also: 分支 · git branch · main branch · 主分支 · git switch

A parallel line of work forked off the main one. However much you change on it, the main line does not move.

When you will meet it

When you set an AI agent loose on your repo, the first instruction should be to work on a branch. Letting it edit the main line means handing over your production copy as scratch paper, and recovery becomes picking through files by hand to see what can stay. On a branch, the worst case is throwing the whole thing away.

An analogy

Like photocopying a document to mark up while the original stays locked in a drawer. If you like the result you merge the markup back; if not you bin the photocopy and the original never moved.

Minimal example

git switch -c agent-try        # 開一條新分支並切過去(舊寫法:git checkout -b)
git branch                     # 列出所有分支,前面有 * 的是你現在所在的這條
git switch main                # 回到主線
git branch -D agent-try        # 整條不要了,連上面的修改一起丟掉

The branch marked with * in git branch output is the one you are currently editing. Much of 'where did my changes go' is really standing on a different branch, with the changes safely sitting there. Note too that your main line may be called main or master — check with git branch first.

What people get wrong

  • Assuming branches are for 'serious developers' and you have no use for one. A branch costs a single command and buys you a permanently clean main line — it is precisely the tool for beginners and for agents.
  • Assuming changes made on a branch automatically appear on the main line. They appear only after a merge; until then the two lines have nothing to do with each other.

Related terms

Next