Perform git partial merges (checkout specific folders from another branch) and squash merges (clean single-commit integration) to selectively integrate changes across branches.
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).
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.
Follow these steps to perform git partial or clean merges:
As a Project Manager, ask the user to clarify:
What type of merge do they need?
For partial merge:
For squash merge:
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:
git stashAs 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"
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"
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
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
| 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 |
Partial Merge:
git diff before committingSquash Merge:
General:
git status frequently to verify stategit checkout main
git checkout feature/new-api -- docs/api
git add docs/api
git commit -m "Update API documentation from feature/new-api"
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
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"
Issue: "error: pathspec 'folder' did not match any file(s) known to git"
git ls-tree -r source-branch --name-onlyIssue: Merge conflicts during squash merge
git add the resolved files and git commitIssue: Accidentally merged wrong folders
git reset HEAD~1 to undo the commit, then repeat with correct pathsIssue: Uncommitted changes blocking checkout
git stash, perform merge, then git stash popnpx skills add X-School-Academy/dev-swarm-git-merge下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer