@allthingsclaude/blueprints 0.3.0-beta.20 → 0.3.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/commands/merge.md +78 -0
- package/package.json +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Detect parent branch and merge the current branch into it
|
|
3
|
+
author: "@markoradak"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Merge into Parent Branch
|
|
7
|
+
|
|
8
|
+
I'll detect which branch the current branch was created from, then merge into it.
|
|
9
|
+
|
|
10
|
+
> **When to use**: You're done working on a feature branch and want to merge it back into the parent branch. This detects the parent automatically so you don't have to remember or type it.
|
|
11
|
+
|
|
12
|
+
## Current State
|
|
13
|
+
|
|
14
|
+
**Working Directory**: !`pwd`
|
|
15
|
+
|
|
16
|
+
**Current Branch**: !`git branch --show-current 2>/dev/null || echo "Not a git repository"`
|
|
17
|
+
|
|
18
|
+
**Status**:
|
|
19
|
+
!`git status --short`
|
|
20
|
+
|
|
21
|
+
**Uncommitted Changes**:
|
|
22
|
+
!`git diff --stat`
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Steps
|
|
27
|
+
|
|
28
|
+
### 1. Preflight checks
|
|
29
|
+
|
|
30
|
+
- Verify we are in a git repository
|
|
31
|
+
- Verify we are NOT on `main` or `master` (refuse to merge main into itself)
|
|
32
|
+
- If there are uncommitted changes, warn the user and stop — they should commit or stash first
|
|
33
|
+
|
|
34
|
+
### 2. Detect the parent branch
|
|
35
|
+
|
|
36
|
+
Run:
|
|
37
|
+
```
|
|
38
|
+
git reflog show --format='%gs' <current-branch> | grep 'branch: Created from' | head -1
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This extracts the reflog entry recorded when the branch was created (e.g. `branch: Created from main`). Parse the branch name from the end of that line.
|
|
42
|
+
|
|
43
|
+
**Fallback** — if the reflog entry is missing (e.g. branch was fetched, not created locally):
|
|
44
|
+
- Compare merge-base distances to `main` and `master`:
|
|
45
|
+
```
|
|
46
|
+
git merge-base --is-ancestor main HEAD && echo main
|
|
47
|
+
git merge-base --is-ancestor master HEAD && echo master
|
|
48
|
+
```
|
|
49
|
+
- If neither works, ask the user to specify the parent branch manually.
|
|
50
|
+
|
|
51
|
+
### 3. Confirm with the user
|
|
52
|
+
|
|
53
|
+
Show:
|
|
54
|
+
- Current branch name
|
|
55
|
+
- Detected parent branch name
|
|
56
|
+
- Summary of commits that will be merged: `git log --oneline <parent>..<current>`
|
|
57
|
+
|
|
58
|
+
**Ask for explicit confirmation before proceeding.** Do NOT merge without user approval.
|
|
59
|
+
|
|
60
|
+
### 4. Check out parent and pull latest
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git checkout <parent>
|
|
64
|
+
git pull
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 5. Merge the current branch
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
git merge <current-branch>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 6. Report result
|
|
74
|
+
|
|
75
|
+
- **Success**: Tell the user the merge completed. Show `git log --oneline -5` so they can see the result.
|
|
76
|
+
- **Conflict**: Tell the user there are merge conflicts. Show `git diff --name-only --diff-filter=U` to list conflicted files. Do NOT attempt to resolve conflicts automatically — let the user decide how to handle them.
|
|
77
|
+
|
|
78
|
+
**Do NOT push. Do NOT delete the feature branch.** Only merge locally. The user can push or clean up when ready.
|
package/package.json
CHANGED