Fusions Git partielles et épurées

VérifiéPrudence

Effectuez des fusions git avancées incluant des fusions partielles (dossiers spécifiques d'une autre branche) et des fusions écrasées (intégration en un seul commit propre).

Spar Skills Guide Bot
DevOpsIntermédiaire
02/03/2026
Claude CodeCursorWindsurfCopilotCodex
#git#merge#version-control#branch-management#squash-merge

Recommandé pour

Synthèse automatique

Guide un agent dans l'exécution de fusions git partielles de dossiers ou fichiers choisis et de fusions squash regroupant une branche en un seul commit.

Points forts

  • Distingue clairement la fusion partielle et la fusion squash avec des étapes dédiées.
  • Vérifie la branche courante et l'état du répertoire de travail avant d'agir.
  • Fournit des commandes exactes et des exemples concrets pour chaque stratégie.
  • Prévoit une étape de vérification via git log, git diff et git status.

Limites

  • N'explique pas la résolution des conflits si le checkout ou le merge échoue.
  • Le checkout partiel écrase les chemins ciblés et peut faire perdre des modifications locales.
  • L'étape de push est incomplète et ne couvre pas les contrôles de sécurité distants.
Quand l'utiliser

À utiliser lorsqu'il faut intégrer uniquement certains dossiers ou fichiers d'une branche, ou regrouper une branche de fonctionnalité en un seul commit.

Quand l'éviter

À éviter pour une fusion complète avec conservation de l'historique ou pour des scénarios complexes de résolution de conflits et de rebase.

Analyse de sécurité

Prudence
Score qualité78/100

No malicious, destructive, exfiltrating, or obfuscated behavior is present; the commands are standard git operations. However, the skill can alter branches, create commits, reset local history, and push to remotes, so it should be treated as a powerful-tool workflow requiring scoped permissions and user confirmation.

Points d'attention
  • •The skill provides shell/git commands that modify repository state, including checkout, merge --squash, commit, reset, and optional push.
  • •No allowed-tools are declared, so the environment permissions for executing bash/git commands are unspecified.
  • •Branch switching, merges, and commits are instructed without an explicit confirmation gate beyond the initial requirements gathering; push is user-confirmed.
  • •No allowed-tools declared, yet the skill's instructions are entirely shell/git commands (checkout, merge --squash, reset, push); if executed, they mutate repository state and rewrite working trees.
  • •Example 2 (`git push origin main`) pushes directly to main without the confirmation step described in Step 5, which conflicts with the skill's own human-in-the-loop guidance.
  • •`git checkout <branch> -- <paths>` overwrites working-tree files in the target branch and can silently discard uncommitted local edits to those paths; the skill only warns about uncommitted changes at the branch-switch level, not per-path.
  • •`git reset HEAD~1` / `git merge --squash` advice is generally safe but the skill does not emphasize verifying the correct target branch before reset/push operations.
Comment cette analyse est faite

Exemples

Partial folder merge
Merge just the docs/ and config/ folders from feature-branch into main, then commit with a message describing the sync.
Squash merge feature
Squash merge feature/user-authentication into main and create a single commit summarizing the JWT and OAuth changes.
Safe partial merge check
I need to partially merge the src/components folder from design-update into release. Check for uncommitted changes first and guide me through the safe steps.

name: dev-swarm-git-merge description: Perform git partial merges (checkout specific folders from another branch) and squash merges (clean single-commit integration) to selectively integrate changes across branches.

AI Builder - Git Partial and Clean Merge

This skill helps you perform advanced git merge strategies including partial merges (checking out specific folders from another branch) and squash merges (clean single-commit integration).

When to Use This Skill

  • User asks to merge specific folders or files from another branch
  • User wants to perform a partial merge without merging the entire branch
  • User asks to squash merge a feature branch into main
  • User wants a clean, single-commit integration without preserving commit history
  • User needs to selectively sync components between branches

Your Roles in This Skill

  • DevOps Engineer: Execute git commands safely, verify branch states, and ensure clean merge operations.
  • Project Manager: Guide the user through merge strategy selection and validate the merge scope.

Role Communication

As an expert in your assigned roles, you must announce your actions before performing them using the following format:

As a {Role} [and {Role}, ...], I will {action description}

This communication pattern ensures transparency and allows for human-in-the-loop oversight at key decision points.

Instructions

Follow these steps to perform git partial or clean merges:

Step 1: Understand the Merge Requirements

As a Project Manager, ask the user to clarify:

  1. What type of merge do they need?

    • Partial merge: Merge specific folders/files only
    • Squash merge: Merge all changes as a single commit
  2. For partial merge:

    • Which source branch contains the folders/files?
    • Which specific folders/files need to be merged?
    • Which target branch should receive them?
  3. For squash merge:

    • Which source branch to merge from?
    • Which target branch to merge into?
    • What should the commit message be?

Step 2: Check Git Status

As a DevOps Engineer, verify the current state:

# Check current branch
git branch

# Check for uncommitted changes
git status

# View recent branches
git branch -a

Important: If there are uncommitted changes, ask the user whether to:

  • Stash them: git stash
  • Commit them first
  • Abort the merge operation

Step 3: Perform the Merge

Option A: Partial Merge (Specific Folders/Files)

As a DevOps Engineer, execute the partial merge:

# Switch to the target branch (where you want the folders)
git checkout target-branch

# Checkout specific folders from source branch
git checkout source-branch -- path/to/folder1 path/to/folder2

# Stage the changes
git add path/to/folder1 path/to/folder2

# Commit the changes
git commit -m "Merge specific folders from source-branch"

Example:

# Merge only the docs and config folders from feature-branch to main
git checkout main
git checkout feature-branch -- docs config
git add docs config
git commit -m "Sync docs and config from feature-branch"

Option B: Squash Merge (Clean Single-Commit)

As a DevOps Engineer, execute the squash merge:

# Switch to target branch
git checkout target-branch

# Perform squash merge (stages all changes but doesn't commit)
git merge --squash source-branch

# Review staged changes
git status

# Commit with a meaningful message
git commit -m "Add feature: descriptive message summarizing all changes"

Example:

# Squash merge a feature branch into main
git checkout main
git merge --squash feature/user-authentication
git commit -m "Add user authentication feature with JWT and OAuth support"

Step 4: Verify the Merge

As a DevOps Engineer, verify the merge was successful:

# Check the commit was created
git log -1

# Verify the changes
git diff HEAD~1

# Check branch status
git status

Step 5: Push Changes (Optional)

As a Project Manager, ask the user if they want to push:

If yes, as a DevOps Engineer:

# Push to remote
git push origin target-branch

Merge Strategy Comparison

| Aspect | Partial Merge | Squash Merge | |--------|---------------|--------------| | Scope | Selective files/folders only | All changes from branch | | Commit History | Not applicable | Squashed into one commit | | Use Case | Selective sync of components | Clean integration of features | | Reversibility | Easy to revert specific files | Reverts entire feature at once |

Best Practices

Partial Merge:

  • Always review changes with git diff before committing
  • Use meaningful commit messages indicating source branch
  • Verify the correct folders/files are staged before committing

Squash Merge:

  • Write comprehensive commit messages that summarize all changes
  • Review all staged changes before committing
  • Document breaking changes or important notes in the commit message
  • Consider keeping the source branch until changes are confirmed working

General:

  • Always work on a clean working directory (commit or stash changes first)
  • Test changes thoroughly after merge
  • Communicate merge strategy with team members
  • Use git status frequently to verify state

Examples

Example 1: Merge Documentation from Feature Branch

git checkout main
git checkout feature/new-api -- docs/api
git add docs/api
git commit -m "Update API documentation from feature/new-api"

Example 2: Squash Merge Feature Branch

git checkout main
git merge --squash feature/shopping-cart
git commit -m "Add shopping cart feature with add/remove/checkout functionality"
git push origin main

Example 3: Merge Multiple Folders

git checkout develop
git checkout feature/redesign -- src/components src/styles
git add src/components src/styles
git commit -m "Merge redesigned components and styles from feature/redesign"

Common Issues

Issue: "error: pathspec 'folder' did not match any file(s) known to git"

  • Solution: The folder/file doesn't exist in the source branch. Verify with git ls-tree -r source-branch --name-only

Issue: Merge conflicts during squash merge

  • Solution: Resolve conflicts manually, then git add the resolved files and git commit

Issue: Accidentally merged wrong folders

  • Solution: If not pushed yet, use git reset HEAD~1 to undo the commit, then repeat with correct paths

Issue: Uncommitted changes blocking checkout

  • Solution: Stash changes with git stash, perform merge, then git stash pop

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/git-partial-and-clean-merges-mm8o52wi/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/git-partial-and-clean-merges-mm8o52wi' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/git-partial-and-clean-merges-mm8o52wi/download' --output '.skill-downloads/git-partial-and-clean-merges-mm8o52wi/SKILL.md.part' && mv '.skill-downloads/git-partial-and-clean-merges-mm8o52wi/SKILL.md.part' '.skill-downloads/git-partial-and-clean-merges-mm8o52wi/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/git-partial-and-clean-merges-mm8o52wi/SKILL.md' && test -s '.skill-downloads/git-partial-and-clean-merges-mm8o52wi/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/dev-swarm-git-merge' && cp -R '.skill-downloads/git-partial-and-clean-merges-mm8o52wi' '.claude/skills/dev-swarm-git-merge'

Cursor
test -f '.skill-downloads/git-partial-and-clean-merges-mm8o52wi/SKILL.md' && test -s '.skill-downloads/git-partial-and-clean-merges-mm8o52wi/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/dev-swarm-git-merge' && cp -R '.skill-downloads/git-partial-and-clean-merges-mm8o52wi' '.cursor/skills/dev-swarm-git-merge'

Codex
test -f '.skill-downloads/git-partial-and-clean-merges-mm8o52wi/SKILL.md' && test -s '.skill-downloads/git-partial-and-clean-merges-mm8o52wi/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/dev-swarm-git-merge' && cp -R '.skill-downloads/git-partial-and-clean-merges-mm8o52wi' '.agents/skills/dev-swarm-git-merge'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/git-partial-and-clean-merges-mm8o52wi'

openskills read 'git-partial-and-clean-merges-mm8o52wi'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/git-partial-and-clean-merges-mm8o52wi/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires