-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit-changes-rules.mdc
More file actions
80 lines (66 loc) · 2.73 KB
/
commit-changes-rules.mdc
File metadata and controls
80 lines (66 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
description: Rules for commiting and pushing changes
globs:
alwaysApply: false
---
# Commit Changes Guidelines
When making changes to the codebase, follow these guidelines for committing your work:
## Analysis Process
1. Run `git --no-pager status` to see which files have changed
2. Run `git --no-pager diff` to see the actual changes in the code
3. Analyze the changes to understand the purpose and impact
## Commit Process
1. Review and stage your changes
2. Prepare a proper commit message (see format below)
3. Commit the changes
4. **CRITICAL: Always push to remote repository after committing WITHOUT asking for confirmation**
5. Remove any temporary files created during the process
## Commit Message Format
- Title: One sentence summary (max 120 characters)
- Empty line
- Body: Bullet list of changes (with NO extra lines between bullet points)
- No additional text
## Example:
```
Add user authentication to login page
- Add password validation function
- Create JWT token generation
- Add error handling for invalid credentials
```
## Git Command Format
For creating commit messages with proper formatting, use one of these approaches:
### Method 1: Build commit message using separate echo commands
```
# Create commit message file line by line
echo "Your commit title" > `.cursor/tmp/commit-msg.txt`
echo "" >> `.cursor/tmp/commit-msg.txt`
echo "- First bullet point" >> `.cursor/tmp/commit-msg.txt`
echo "- Second bullet point" >> `.cursor/tmp/commit-msg.txt`
echo "- Third bullet point" >> `.cursor/tmp/commit-msg.txt`
# Commit using the file and clean up, then AUTOMATICALLY push without confirmation
git commit -F `.cursor/tmp/commit-msg.txt` && rm `.cursor/tmp/commit-msg.txt` && git push
```
### Method 2: For simple commits, use the -m flag twice
```
# Commit and AUTOMATICALLY push without confirmation
git commit -m "Your commit title" -m "- First bullet point" && git push
```
## Important
- Always create temporary files in the `.cursor/tmp/` folder and clean them up after completing the commit process to avoid cluttering the workspace.
- **Never leave commits unpushed** - changes must be pushed to the remote repository to ensure they are backed up and accessible to other team members.
- **Never ask for confirmation when pushing** - always push automatically after commit.
- If you encounter push errors, resolve them immediately before continuing with other tasks.
## Complete Git Workflow Example
```
# Check status and diff
git --no-pager status
git --no-pager diff
# Stage and commit changes, then AUTOMATICALLY push without confirmation
git add .
git commit -m "Your descriptive title" -m "- Detailed change description" && git push
# If push fails, pull latest changes and try again
if [ $? -ne 0 ]; then
git pull --rebase
git push
fi
```