Skip to content

Commit 024bba5

Browse files
feat(commands): add git-push command for pushing commits to remote
1 parent 57779c6 commit 024bba5

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

.opencode/commands/git-push.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
description: Push commits to remote repository
3+
agent: build
4+
model: github-copilot/claude-haiku-4.5
5+
---
6+
7+
You are about to push commits to the remote git repository. Follow these steps carefully:
8+
9+
## Step 1: Analyze Current State
10+
11+
Check the current git state:
12+
!`git status`
13+
14+
View commits to be pushed:
15+
!`git log --oneline @{u}..HEAD`
16+
17+
View remote tracking information:
18+
!`git branch -vv`
19+
20+
## Step 2: Check for Commits to Push
21+
22+
Before proceeding, check if there are any commits to push:
23+
24+
!`git log --oneline @{u}..HEAD`
25+
26+
If there are NO commits to push, inform the user:
27+
```
28+
No commits found to push. Your local branch is already up to date with the remote.
29+
30+
If you want to commit changes, please use:
31+
- git-stage-commit-push (to stage, commit and push)
32+
- git-commit-push (to commit staged changes and push)
33+
```
34+
35+
Then stop the process.
36+
37+
## Step 3: Present Summary to User
38+
39+
If there ARE commits to push, you MUST:
40+
41+
1. **Analyze commits to be pushed**
42+
2. **Provide a clear, concise summary** to the user including:
43+
- The number of commits to be pushed
44+
- Brief description of each commit
45+
- The target branch and remote
46+
- Any warnings about force push or conflicts
47+
3. **Ask for confirmation** before proceeding with the push
48+
49+
Example summary format:
50+
```
51+
I found the following commits ready to push:
52+
53+
1. refactor(utils): improve validation logic with better error handling
54+
2. test(utils): add unit tests for validation
55+
56+
Target: origin/main (2 commits ahead)
57+
58+
Is it okay to proceed with pushing these commits?
59+
```
60+
61+
## Step 4: Push to Remote
62+
63+
Only after receiving user confirmation:
64+
65+
1. Push to the remote repository: `git push`
66+
2. If push fails:
67+
- Show the error message to the user
68+
- Explain what went wrong (e.g., conflicts, rejected push, authentication issues)
69+
- Suggest solutions if applicable
70+
- Do not force push unless the user explicitly requests it
71+
3. Verify the push was successful: `git status`
72+
73+
## Important Notes
74+
75+
- **DO NOT** push without user confirmation
76+
- **NEVER** force push to main/master branch unless user explicitly requests it
77+
- **DO** warn the user if they're about to force push
78+
- **DO** provide clear feedback on what was pushed
79+
- **DO** handle any errors gracefully and report them to the user
80+
- **NOTE**: This command ONLY pushes existing commits (no staging or committing occurs)
81+
82+
## Example Workflow
83+
84+
1. Show commits to be pushed ✓
85+
2. Show target branch and remote ✓
86+
3. Ask: "Is it okay to proceed with pushing?" ✓
87+
4. Wait for user confirmation ✓
88+
5. Push: `git push`
89+
6. Verify: `git status`
90+
7. Confirm: "✓ Commits pushed successfully to origin/main"

0 commit comments

Comments
 (0)