Merge pull request 'agentws: check out --branch from origin when it exists' (#17) from benvin/agentws-branch-checkout into main
Reviewed-on: #17
This commit was merged in pull request #17.
This commit is contained in:
@@ -109,10 +109,10 @@ checkout too; the worktrees themselves live under the **worktree root**
|
||||
|
||||
```bash
|
||||
# Clone unkin/argocd-apps into ~/src/prodenv if missing, then add a worktree for
|
||||
# a new branch off the remote default branch. Prints the worktree path.
|
||||
# the branch. Prints the worktree path.
|
||||
agentws new argocd-apps --branch benvin/my-change
|
||||
|
||||
# Branch off a specific base instead of the remote default
|
||||
# Branch off a specific base instead of the remote default (new branches only)
|
||||
agentws new argocd-apps --branch benvin/hotfix --from release-1.2
|
||||
|
||||
# List managed worktrees (repo, branch, path)
|
||||
@@ -136,6 +136,20 @@ agentws clean
|
||||
agentws token
|
||||
```
|
||||
|
||||
`agentws new` fetches first, then takes one of two paths and names the one it
|
||||
took on its last output line. A branch that **already exists on origin** is
|
||||
checked out at `origin/<branch>` and set to track it, so the worktree starts on
|
||||
the branch's own commits (`branch <b> (tracking origin/<b> at <sha>)`); a local
|
||||
branch left from an earlier run is fast-forwarded onto it. A branch origin does
|
||||
**not** have is created from `--from`, or from the remote's default branch when
|
||||
`--from` is absent (`branch <b> (new, from origin/<base>)`) — the default is read
|
||||
from `origin/HEAD`, so a repo on `master` forks from `master`. `--from` is
|
||||
ignored, with a note, when the branch is already on origin.
|
||||
|
||||
The one case the worktree does not land on `origin/<branch>` is a local branch
|
||||
carrying commits origin has never seen. Those commits exist nowhere else, so the
|
||||
checkout is left on them and the output says how many.
|
||||
|
||||
### prune
|
||||
|
||||
`agentws prune` finds worktrees two ways and merges the results: the managed
|
||||
|
||||
Reference in New Issue
Block a user