Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
cherry-pick-commits.chatmode.md79 linesDownload Raw Back to chatmodes
1# Cherry-Pick Commits Between Branches2 3Cherry-pick recent commits from a source branch to a target branch without switching branches.4 5## Instructions for Copilot6 71. **Confirm branches with the user**8   - Ask the user to confirm the source and target branches9   - If different branches are needed, update the configuration10 112. **Identify unique commits**12   - Run: `git log <target-branch>..<source-branch> --oneline --reverse`13   - **IMPORTANT**: The commit count may be misleading if branches diverged from different base commits14   - Compare the LAST few commits from each branch to identify actual missing commits:15     - `git log <source-branch> --oneline -10`16     - `git log <target-branch> --oneline -10`17   - Look for commits with the same message but different SHAs (rebased commits)18   - Show the user ONLY the truly missing commits (usually just the most recent ones)19 203. **Confirm with user before proceeding**21   - If the commit count seems unusually high (e.g., 400+), STOP and verify semantically22   - Ask: "I found X commits to cherry-pick. Shall I proceed?"23   - If there are many commits, warn that this may take time24 254. **Execute the cherry-pick**26   - Ensure the target branch is checked out first27   - Run: `git cherry-pick <sha1>` for single commits28   - Or: `git cherry-pick <sha1> <sha2> <sha3>` for multiple commits29   - Apply commits in chronological order (oldest first)30 315. **Handle any issues**32   - If conflicts occur, pause and ask user for guidance33   - If empty commits occur, automatically skip with `git cherry-pick --skip`34 356. **Verify and report results**36   - Run: `git log <target-branch> -<number-of-commits> --oneline`37   - Show the user the newly applied commits38   - Confirm the branch is now ahead by X commits39 40## Key Git Commands41 42```bash43# Find unique commits (may show full divergence if branches were rebased)44git log <target>..<source> --oneline --reverse45 46# Compare recent commits on each branch (more reliable for rebased branches)47git log <source-branch> --oneline -1048git log <target-branch> --oneline -1049 50# Cherry-pick specific commits (when target is checked out)51git cherry-pick <sha1>52git cherry-pick <sha1> <sha2> <sha3>53 54# Skip empty commits55git cherry-pick --skip56 57# Verify result58git log <target-branch> -<count> --oneline59```60 61## Common Scenarios62 63- **Empty commits**: Automatically skip with `git cherry-pick --skip`64- **Conflicts**: Stop, show files with conflicts, ask user to resolve65- **Many commits**: Warn user and confirm before proceeding66- **Already applied**: These will result in empty commits that should be skipped67- **Diverged branches**: If branches diverged (rebased), `git log` may show the entire history difference68  - The actual missing commits are usually only the most recent ones69  - Compare commit messages from recent history on both branches70  - Cherry-pick only commits that are semantically missing71 72## Workflow Style73 74Use an interactive, step-by-step approach:75- Show output from each command76- Ask for confirmation before major actions77- Provide clear status updates78- Handle errors gracefully with user guidance79