merge-branch-into-current
Merge Branch Into Current
Scope
Use this skill inside a Git repository when the goal is to merge one branch into the current branch and keep an explicit merge commit.
Default behavior:
- Target branch: the current branch
- Source branch: the branch explicitly provided by the user
- Merge strategy:
git merge --no-ff - Dirty-check scope: the current worktree plus any active worktree that is currently checked out on the source or target branch
Do not use squash merge or rebase unless the user explicitly overrides the request.
Workflow
1. Resolve branch names
Collect:
- source branch, called "specified branch"
- target branch, called "current branch"
If the user gave both names, use them directly after verifying they exist.
If the user did not give names, inspect the repository:
git branch --show-current
git branch --format='%(refname:short)'
If the current branch is main, and there is exactly one local branch that satisfies all of the following, auto-select it as the source branch and continue without asking:
- it is not
main - it is not merged into
main git rev-list --count main..BRANCHis at least1
In that case:
- source branch = that unmerged branch
- target branch =
main
If the auto-detection rule does not produce exactly one source branch, stop and ask the user for the source branch name. Target branch remains the current branch unless the user states otherwise.
2. Preflight checks
Verify the repository and branch state before merging:
git rev-parse --show-toplevel
git branch --show-current
git show-ref --verify --quiet refs/heads/<source-branch>
git show-ref --verify --quiet refs/heads/<target-branch>
The merge must run from a worktree currently checked out on the target branch. If the current worktree is not on the target branch, stop and tell the user to switch first.
3. Dirty-check both branches
Run the bundled script:
scripts/merge_branch_into_current.sh [source-branch] [target-branch]
The script must:
- inspect
git worktree list --porcelain - find any active worktree checked out on the source or target branch
- run
git status --shortinside each matching worktree - abort if either branch has uncommitted tracked or untracked changes
If a matching branch has no active worktree, treat it as clean because Git cannot hold uncommitted state for that branch without a checked-out worktree.
When aborting, clearly report which branch and which worktree path is dirty, and tell the user to整理 or commit/stash those changes before retrying.
4. Merge
If both branches are clean, run:
git merge --no-ff <source-branch>
This preserves a merge commit even when fast-forward would be possible.
If merge conflicts occur:
- stop immediately
- report the conflicted files from
git status --short - do not auto-resolve unless the user asks
5. Report result
On success, report:
- source branch
- target branch
- resulting merge commit SHA from
git rev-parse HEAD
Resources
scripts/
merge_branch_into_current.sh: resolves branches when possible, checks worktree cleanliness for the source and target branches, and runsgit merge --no-ff.
More from hu-wentao/wyatt_skills
clear-flutter-env
用于在 macOS 上清除 Flutter 环境变量 (FLUTTER_STORAGE_BASE_URL 和 PUB_HOSTED_URL)。适用于需要重置环境或解决 Flutter 代理问题的场景。
16publish-flutter-package
Automates the Flutter package release process via git tags and GitHub Actions. Handles multi-package workspaces, SemVer versioning suggestions based on git history, updating pubspec.yaml and CHANGELOG.md, and dry-run validation. Use when the user wants to "release", "publish", or "version" a Flutter package.
15git-worktree
Create a git worktree for the current repository at the same directory level as the project root. This skill automates branch creation, directory naming according to the format project-T-branch, and initial project setup (e.g., dependency installation). Use this when the user wants to work on a new feature or fix without switching their current workspace.
14update-wyatt-skills
用于更新 'wyatt_skills'仓库包含的技能集合, 当用户需要更新skills调用.
13release-dart-package-action
Automates the Flutter package release process via git tags and GitHub Actions. Handles multi-package workspaces, SemVer versioning suggestions based on git history, updating pubspec.yaml and CHANGELOG.md, and dry-run validation. Use when the user wants to "release", "publish", or "version" a Flutter package.
2release-flutter-web-s3
Prepare, build, and publish a Flutter Web app to S3-compatible object storage. Use when Codex needs to bump or update pubspec.yaml version, create a Flutter Web release tag, configure a reusable S3 deployment script, build build/web, upload or promote web assets, or inspect a Flutter Web S3 release workflow.
1