git-merge
Skill3 starsChanged 24 days agoMITView on GitHub
Merge a source branch into a target with `git merge --no-ff`, always producing a merge commit whose message is drafted inline per .gitmessage and committed via a heredoc. Use for "merge X into Y", "merge X", or the divergence merge that git-pull or git-push suggests. Local only, with no push, pull, rebase, branch cleanup, or conflict auto-resolution.
- Reads credentials
- Deletes or force-pushes
- Commits and pushes
8 other projects use a version of this.
Adopted by
Most recently taken up by
- Zenobia000/agent-skills-startertheir own version, first seen Nov 1, 2026
- MithunWijayasiri/dotclaudetheir own version, first seen Oct 26, 2026
- futex-ai/skillstheir own version, first seen Oct 25, 2026
- microsoft/hve-coretheir own version, first seen Oct 13, 2026
- cognis-digital/skillsmiththeir own version, first seen Oct 11, 2026
- aws-solutions/konductortheir own version, first seen Sep 23, 2026
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- microsoft/hve-core★ 1.6ksame name
- aws-solutions/konductor★ 12same name
- Cogni-AI-OU/cogni-ai-agent-skills★ 4same name
- MithunWijayasiri/dotclaude★ 4same name
- Zenobia000/agent-skills-starter★ 4same name
- ogromwang/skills★ 2same name
- futex-ai/skills★ 1same name
- cognis-digital/skillsmith★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- git-branch-createSkill
- git-branch-deleteSkill
- git-commitSkill
- git-fetchSkill
- git-pullSkill
- git-pushSkill
- git-tagSkill
- hf-downloadSkill
- hf-setupSkill
- hf-uploadSkill
- py-env-setupSkill
- repo-docsSkill
- repo-initSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
28 rules. 0 are common, 12 are distinctive, and 16 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
12
Distinctive
This author's own choices. Worth a look.
16
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 9
Run a single git merge --no-ff <source> against the current HEAD, then commit the merge with a .gitmessage-compliant message drafted inline.
- Distinctive: line 27
Run every command in this skill in a POSIX shell.
- Very specific: line 33
If source == target, refuse with a one-line explanation.
- Very specific: line 49
Align HEAD with target: Run these independent reads: git branch --show-current (empty output means detached.
- Distinctive: line 52
abort: STOP; no git state has been modified.
- Very specific: line 56
checkout: run git checkout --no-overwrite-ignore <target>, then proceed to step 3.
- Very specific: line 60
Verify remote state (targeted fetch): Follow the step-3 section of references/remote-check.md: one targeted fetch per local-side ref, from …
- Very specific: line 63
abort (Recommended): STOP. Suggest git-pull with <stale-branch> to refresh it, then re-run this skill.
- Distinctive: line 68
Gather state: Run these independent reads:
- Distinctive: line 74
Do NOT re-run git status --short.
- Very specific: line 78
Refuse on no-op: If git log <target-ref>..<source-ref> is empty, STOP and tell the user there is nothing to merge.
- Distinctive: line 104
Ask with a choice question: merge / edit / abort.
- Distinctive: line 107
abort: stop. No git state has been modified.
- Distinctive: line 110
Run the merge: Always run, in sequence:
- Very specific: line 127
When <source> is a short-lived branch that is now fully contained in <target>, one line that suggests git-branch-delete with <source> as …
- Very specific: line 128
When <target> is main and <source> matches release/* or hotfix/*, one line that suggests git-tag for the release or patch tag that …
- Very specific: line 129
When step 4 was answered with proceed anyway, repeat the stale or diverged finding verbatim and suggest git-pull with <branch> plus a …
- Very specific: line 137
NEVER write the merge commit message to a file on disk (no tmp/commit_msg.txt, no .git/COMMIT_EDITMSG pre-population, no scratch file under …
- Distinctive: line 138
NEVER merge onto a detached HEAD.
- Distinctive: line 140
NEVER delete, move, or overwrite an ignored or untracked file that blocks the checkout or merge (steps 2 and 7).
- Distinctive: line 141
NEVER treat a failed step-5 read as an empty result.
- Very specific: line 143
NEVER delete or modify the source branch after merging.
- Distinctive: line 144
NEVER auto-resolve conflicts, run git merge --abort, or run git reset --hard to recover from a failed merge.
- Very specific: line 145
NEVER use --force, --strategy=ours, --strategy-option=theirs, or any flag that hides conflicts.
- Very specific: line 146
NEVER pass --ff or --ff-only, and NEVER omit --no-ff.
- Very specific: line 147
NEVER pass --no-verify or --no-gpg-sign on the git commit that follows git merge --no-ff --no-commit.
- Very specific: line 148
NEVER add any AI tool, model, agent, or vendor attribution: no Co-Authored-By: trailer naming an assistant or its vendor, and no Generated …
- Distinctive: line 150
NEVER skip the step 9 confirmation, and NEVER skip the step 4 prompt when remote divergence is detected.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Goal
Run a single git merge --no-ff <source> against the current HEAD, then commit the merge with a .gitmessage-compliant message drafted inline. Every merge generates a merge commit, so the source branch's topology stays visible in git log --graph.
The only network calls are the step-3 per-ref git fetch refreshes of origin/<ref> remote-tracking refs; another remote (such as template) is never fetched here. A stale or diverged local ref is shown and confirmed before continuing (step 4).
The merge commit message follows .gitmessage through git-commit's message spec (see the Reference section).
When NOT to use
- The branch only needs to catch up with its own remote and has no local commits:
git-pullfast-forwards without a merge commit. - The user wants remote state inspected broadly:
git-fetch. - The user wants the merge result published:
git-push. - The source branch is already merged and only needs removing:
git-branch-delete. - The repo declares
trunk-soloin.gitmessageand the user simply wants their work on the trunk: committing directly onmainis that variant's sanctioned path, sogit-commitis the whole answer and no merge is involved.
Procedure
Terms such as choice question, independent reads, invoke, and suggest follow AGENTS.md (Skill authoring); in a non-interactive session every gate ends this skill.
Run every command in this skill in a POSIX shell; the redirections and heredocs used across this skill family are POSIX syntax and break under PowerShell.
- Resolve source and target.
- Explicit form ("merge X into Y" / "merge X to Y" / "merge X onto Y"): source=X, target=Y.
- Single-branch form ("merge X"): source=X, target=the current branch (matching plain
git merge Xsemantics), read withgit branch --show-current. Empty output means HEAD is detached and there is no target yet: skip the gate below; step 2 asks for one before anything else runs. - No-arg form ("merge"): STOP and ask with a choice question for both. Do not guess.
- If
source == target, refuse with a one-line explanation. - Classify the source. Run
git remoteonce. A source of the form<remote>/<branch>whose<remote>that output lists (for exampleorigin/main, ortemplate/mainaftergit remote rename origin template) is a remote-tracking source; any other source, such asfeature/fooin a repo with nofeatureremote, is a local source. When bothrefs/heads/<source>andrefs/remotes/<source>resolve (git rev-parse --verify --quieton each), ask with a choice question which one is meant (local branch / remote-tracking ref); do not guess. - Exact name check, before any other step, for every local branch name (
<target>, even when it is the current branch, a local<source>, and a step-2 alternate target; skip only a current-branch<target>whilegit rev-parse --verify --quiet HEADprints nothing): require[ "$(git for-each-ref --format='%(refname)' "refs/heads/<b>")" = "refs/heads/<b>" ]. On failure, STOP: list the local branches whose names match ignoring case (git for-each-ref --format='%(refname:lstrip=2)' refs/heads/ | grep -ixF -- '<b>'), or say there is no local<b>; for a current-branch<target>, suggestgit switch <exact-name>. On a case-insensitive filesystemMainresolves tomain(also as HEAD aftergit checkout Main), so the merge would land onmainpast the gate below; the equality is needed becausefor-each-refalso matches branches underrefs/heads/<b>/. - Full refs. Local reads and the merge itself name each side by its full ref, so a tag sharing the short name cannot be picked instead:
<target-ref>isrefs/heads/<target>, and<source-ref>isrefs/remotes/<source>for a remote-tracking source, elserefs/heads/<source>. Protected-target gate. Read the
Workflow:line in.gitmessage's "Workflow Variant" section to get the protected set. When no variant is declared, or the line carries an unrecognized value (such as the shipped<not recorded>placeholder), assumegit-flow; do not infer a permissive one here. Nothing infers the variant:git-commitandrepo-initask the user and offer to record the answer.Variant Protected set git-flowmain,develop,support/*github-flowmain,support/*trunk-solonone This table is a convenience copy.
.gitmessage's "Protected Branches" section is normative; when the two disagree, follow.gitmessageand say so.Compare names ignoring case:
Main,DEVELOP, andSupport/xcount as protected. A merge commit on a protected target is a direct commit there, so if<target>is in that set, require an explicit in-turn opt-in as AGENTS.md defines it: a reply in the current turn that names the direct merge and<target>, typed (such as "yes, merge directly into<target>") or by choosing an option whose label states both. A generic yes, or an opt-in from an earlier turn, does NOT count. Without one, STOP before any checkout or fetch and explain the alternative: open a PR or MR from<source>into<target>, or re-ask with the opt-in. The divergence merge thatgit-pullorgit-pushsuggests (target=<branch>, source=origin/<branch>) is gated the same way. If the set is empty (trunk-solo), skip this gate.
- Align HEAD with target. Run these independent reads:
git branch --show-current(empty output means detached; an unborn branch prints its name; unlikegit symbolic-ref --short HEAD, it never printsheads/<branch>) andgit status --short. This status capture is the single canonical read and is reused by step 7.- HEAD detached and no target yet (single-branch form): STOP; a merge commit here would land on no branch. Ask with a choice question:
- choose: take a local branch name as the target in free text, then re-run the step-1 exact name check, the protected-target gate, and step 2 with it.
- abort: STOP; no git state has been modified.
- HEAD already equals the target: proceed to step 3.
- Tree dirty (status non-empty): STOP and suggest
git-commit, sogit checkoutcannot carry uncommitted edits across branches. - Tree clean and HEAD differs from target: ask with a choice question with three options:
- checkout: run
git checkout --no-overwrite-ignore <target>, then proceed to step 3. The flag makes checkout fail instead of silently replacing an ignored file (such as.env) that<target>tracks;git status --shortnever shows ignored files. On failure, surface the verbatim error and stop; never delete the blocking files. - abort: STOP; no git state has been modified.
- choose: take an alternate target name as free text, then re-run the step-1 exact name check, the protected-target gate, and step 2 with it. The same three options reappear until the user picks checkout or abort.
- checkout: run
- HEAD detached and no target yet (single-branch form): STOP; a merge commit here would land on no branch. Ask with a choice question:
- Verify remote state (targeted fetch). Follow the step-3 section of
references/remote-check.md: one targeted fetch per local-side ref, fromoriginonly, read-only against the working tree. Decide based on remote divergence. Classify each eligible ref per the step-4 section of
references/remote-check.md. If any is stale (local behind) or diverged, render the per-ref findings it lists and ask with a choice question:- abort (Recommended): STOP. Suggest
git-pullwith<stale-branch>to refresh it, then re-run this skill. - proceed anyway: continue with the local refs as-is, and record the choice so step 12 repeats the warning.
In the suggested divergence merge the target is usually diverged by construction; this prompt is the explicit reconfirmation point and is NOT skipped on the assumption that the user already saw the divergence in the report of
git-pullorgit-push.- abort (Recommended): STOP. Suggest
Gather state. Run these independent reads:
git rev-parse --verify <source-ref>(source must resolve).git log <target-ref>..<source-ref> --oneline(commits the merge will land).git diff --stat <target-ref>...<source-ref>(body fuel; three dots diff from the merge base, so target-only changes do not show reversed).git log -1 --format='%H %s'(so a hook failure can be diagnosed against the last commit).
Do NOT re-run
git status --short; step 2 already captured it.A non-zero exit from any of these reads is an error, never an empty list: surface it verbatim and stop. An unborn target, for example, fails the
git logrange read; it has no commit to merge into.- Refuse on no-op. If
git log <target-ref>..<source-ref>is empty, STOP and tell the user there is nothing to merge. - Refuse on dirty tree or files in the way. If the step-2 status capture is non-empty, STOP and suggest
git-commitfirst. Do NOT stash; merging over a dirty tree entangles unrelated edits into the merge commit. Then list the untracked or ignored files on disk at a path the source adds, or at a parent of one (an ignored fileddwhere the source addsdd/inner);git status --shorthides ignored ones, andgit mergesilently overwrites them even with--no-overwrite-ignore:top=$(git rev-parse --show-toplevel) && git diff --name-only -z --no-renames --diff-filter=A <target-ref> <source-ref> | tr '\0' '\n' | while IFS= read -r p; do q=$p while :; do if [ -L "$top/$q" ] || { [ -e "$top/$q" ] && { [ "$q" = "$p" ] || [ ! -d "$top/$q" ]; }; }; then [ -n "$(git --literal-pathspecs ls-tree --full-tree --name-only <target-ref> -- "$q")" ] || echo "file in the way: $q"; break fi case $q in */*) q=${q%/*} ;; *) break ;; esac done done | sort -uls-treeskips a path<target>tracks; Git Bash may rewrite a<ref>:<path>argument (such asx:.env). Any output: STOP and list the paths; the user moves or backs them up (often.env-style local config), then re-runs this skill. Never delete them. - Plan the merge. Compose the draft per the Reference section below. Pick
<scope>per.gitmessage:feature/<scope>/<desc>source: use<scope>.- Otherwise infer the dominant scope from
git diff --stat <target-ref>...<source-ref>; fall back torepofor cross-area integrations (for example back-mergingmaininto a feature branch).
- Show the plan and confirm.
- Display the commits about to land (
git log <target-ref>..<source-ref> --oneline) and the exact two-command sequence from step 10. - Render the drafted merge commit message as a fenced code block immediately above the question.
- Ask with a choice question: merge / edit / abort.
- merge: proceed to step 10 with the current draft.
- edit: apply the user's free-text edits, re-render the draft inline, re-ask. Loop until approved or aborted.
- abort: stop. No git state has been modified.
- A bare "merge" / "yes merge" / "go ahead" typed in the current turn counts as confirmation; ambiguous replies do not.
- Display the commits about to land (
- Run the merge. Always run, in sequence:
The quoted heredoc terminator prevents shell expansion of the body; if the draft contains a line equal togit merge --no-ff --no-commit <source-ref> git commit -F - <<'COMMIT_MSG_EOF' <approved message substituted verbatim, preserving the blank line between header and body> COMMIT_MSG_EOFCOMMIT_MSG_EOF, pick a fresh terminator (for exampleCOMMIT_MSG_EOF_2) absent from that body. Ifgit merge --no-ff --no-commitfails, do NOT proceed togit commit; handle per step 11. - Handle failures. Do NOT retry blindly.
- Conflicts (
git diff --name-only --diff-filter=Unon-empty): list the conflicted files and STOP. Tell the user to resolve them; once resolved, ask this skill to finish (the approved draft is still in the conversation and the same step-10 heredoc commits it), or they can rungit merge --abortthemselves to back out. - Hook failure on the commit step: the merge index is still in place and the approved draft is still in the conversation. Surface stderr verbatim and stop. After the user fixes the issue, re-run the step-10
git commit -F -heredoc with the still-approved draft. - Other: surface verbatim and stop.
- Conflicts (
- Report success. Show:
- The new target tip (
git log -1 --format='%h %s'), which is the merge commit. git log --oneline --graph -5 <target-ref>so the user can confirm the topology.- When
<source>is a short-lived branch that is now fully contained in<target>, one line that suggestsgit-branch-deletewith<source>as the optional next step. - When
<target>ismainand<source>matchesrelease/*orhotfix/*, one line that suggestsgit-tagfor the release or patch tag that.gitmessage's flow requires on this merge commit. - When step 4 was answered with proceed anyway, repeat the stale or diverged finding verbatim and suggest
git-pullwith<branch>plus a follow-up integration before the next push, so the warning is not silently lost.
- The new target tip (
Reference: merge commit message specification
.gitmessage is normative. Its detailed reading for this skill family lives in the git-commit skill, at ../git-commit/references/message-spec.md relative to this skill's directory; this skill depends on git-commit being installed alongside it. Read that file and apply its "Merge commit message" section; where it and .gitmessage disagree, follow .gitmessage and say so.
Hard rules
- NEVER write the merge commit message to a file on disk (no
tmp/commit_msg.txt, no.git/COMMIT_EDITMSGpre-population, no scratch file under the repo root, system tmp, or/var/tmp). The message lives only in the chat conversation and the heredoc that feedsgit commit -F -. - NEVER merge onto a detached HEAD. The merge commit would belong to no branch; step 2 asks for a target branch instead.
git checkoutis permitted ONLY in the step-2 approve path, always with--no-overwrite-ignore, and never against a path that was not named as the resolved target or the user-supplied alternate, after that name passed the step-1 exact name check.- NEVER delete, move, or overwrite an ignored or untracked file that blocks the checkout or merge (steps 2 and 7). Surface it and let the user decide.
- NEVER treat a failed step-5 read as an empty result.
- NEVER
git push,git pull, orgit rebase. The only network calls permitted are the step-3 per-ref targeted fetches fromorigin, scoped to the local-side refs in the merge, with no--force,--prune, or--tags; the+on the step-3 remote-tracking refspec is the only forced update allowed, and it never names a local branch. A broader origin sweep belongs togit-fetch, and any other remote (such astemplate) is fetched by the user withgit fetch <remote>, never by this skill. - NEVER delete or modify the source branch after merging. Cleanup belongs to
git-branch-delete; suggest it in the step-12 report, never invoke it. - NEVER auto-resolve conflicts, run
git merge --abort, or rungit reset --hardto recover from a failed merge. Surface the obstruction and let the user decide. - NEVER use
--force,--strategy=ours,--strategy-option=theirs, or any flag that hides conflicts. - NEVER pass
--ffor--ff-only, and NEVER omit--no-ff. Fast-forward is out of scope for this skill. - NEVER pass
--no-verifyor--no-gpg-signon thegit committhat followsgit merge --no-ff --no-commit. - NEVER add any AI tool, model, agent, or vendor attribution: no
Co-Authored-By:trailer naming an assistant or its vendor, and noGenerated with <tool>line. Do not invent co-authors. The message MUST follow.gitmessage, stay in concise bullet form, and stay human-authored. - NEVER merge into a branch the active workflow variant protects without an explicit in-turn opt-in (step 1) that names the direct merge and the target; target names match the protected set ignoring case. A generic yes or prior-turn approval does not count, and an undeclared or unrecognized variant value means
git-flow, never the most permissive. - NEVER skip the step 9 confirmation, and NEVER skip the step 4 prompt when remote divergence is detected. Proceeding silently against a stale ref is the exact failure mode that prompt prevents.
- This skill does NOT commit unrelated edits, push, pull, rebase, or clean up branches. When those are needed, surface the situation and suggest the matching skill (
git-commit,git-push,git-pull,git-fetch) without running it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

