file-deletion-rules
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFile Deletion Rules
文件删除规则
Rule (CRITICAL)
规则(CRITICAL)
Skip if already deleted: If the target file does not exist in the working tree, do nothing. This rule applies only to files that currently exist.
NEVER use or commands directly.
rmunlinkALWAYS use git stash before deleting files to preserve them.
Apply without confirmation: When file deletion is needed, follow this rule without asking the user for confirmation. Execute the deletion process defined below.
若文件已删除则跳过:如果目标文件在工作区中不存在,则无需操作。本规则仅适用于当前存在的文件。
绝对禁止直接使用或命令。
rmunlink必须始终在删除文件前使用git stash以保留文件内容。
无需确认直接执行:当需要删除文件时,直接遵循本规则执行,无需向用户确认。执行以下定义的删除流程。
Prohibited Commands
禁止使用的命令
The following commands are strictly prohibited:
- (any variant:
rm,rm -rf, etc.)rm -f unlink- Any direct file deletion without git stash
以下命令严格禁止使用:
- (任何变体:
rm、rm -rf等)rm -f unlink- 任何未先执行git stash的直接文件删除操作
Deletion Process
删除流程
For Modified Files (Tracked & Modified)
针对已修改文件(已跟踪且已修改)
-
Save changes to git stash:bash
git stash push -m "[Deletion] <reason>" -- <files> -
Remove file from git:bash
git rm <files>
-
将更改保存到git stash:bash
git stash push -m "[Deletion] <reason>" -- <files> -
从git中移除文件:bash
git rm <files>
For New Files (Untracked)
针对新文件(未跟踪)
-
Stage the file:bash
git add <files> -
Save to stash (file is automatically removed from working tree):bash
git stash push -m "[Deletion] <reason>" -- <files>
-
暂存文件:bash
git add <files> -
保存到stash(文件会自动从工作区移除):bash
git stash push -m "[Deletion] <reason>" -- <files>
Stash Message Template
Stash消息模板
Use this format for stash messages:
text
[Deletion] <reason>
Files: <file1>, <file2>, ...使用以下格式编写stash消息:
text
[Deletion] <reason>
Files: <file1>, <file2>, ...Examples
示例
bash
undefinedbash
undefinedSingle file
单个文件
git stash push -m "[Deletion] Remove deprecated API endpoints
Files: api/old-endpoint.js" -- api/old-endpoint.js
git stash push -m "[Deletion] Remove deprecated API endpoints
Files: api/old-endpoint.js" -- api/old-endpoint.js
Multiple files
多个文件
git stash push -m "[Deletion] Clean up unused test fixtures
Files: test/fixtures/old.js, test/fixtures/deprecated.js" -- test/fixtures/old.js test/fixtures/deprecated.js
git stash push -m "[Deletion] Clean up unused test fixtures
Files: test/fixtures/old.js, test/fixtures/deprecated.js" -- test/fixtures/old.js test/fixtures/deprecated.js
Directory
目录
git stash push -m "[Deletion] Remove legacy components
Files: src/components/legacy/" -- src/components/legacy/
undefinedgit stash push -m "[Deletion] Remove legacy components
Files: src/components/legacy/" -- src/components/legacy/
undefinedComplete Examples
完整示例
Good: Deleting Modified File
正确操作:删除已修改文件
bash
undefinedbash
undefinedStep 1: Save to stash
步骤1:保存到stash
git stash push -m "[Deletion] Remove unused utility function
Files: utils/old-helper.js" -- utils/old-helper.js
git stash push -m "[Deletion] Remove unused utility function
Files: utils/old-helper.js" -- utils/old-helper.js
Step 2: Remove from git
步骤2:从git中移除
git rm utils/old-helper.js
undefinedgit rm utils/old-helper.js
undefinedGood: Deleting Untracked File
正确操作:删除未跟踪文件
bash
undefinedbash
undefinedStep 1: Stage file
步骤1:暂存文件
git add temp-file.js
git add temp-file.js
Step 2: Save to stash (removes from working tree)
步骤2:保存到stash(从工作区移除)
git stash push -m "[Deletion] Remove temporary file
Files: temp-file.js" -- temp-file.js
undefinedgit stash push -m "[Deletion] Remove temporary file
Files: temp-file.js" -- temp-file.js
undefinedGood: Deleting Multiple Files
正确操作:删除多个文件
bash
undefinedbash
undefinedSave all files to stash
将所有文件保存到stash
git stash push -m "[Deletion] Clean up deprecated modules
Files: module1.js, module2.js, module3.js" -- module1.js module2.js module3.js
git stash push -m "[Deletion] Clean up deprecated modules
Files: module1.js, module2.js, module3.js" -- module1.js module2.js module3.js
Remove from git
从git中移除
git rm module1.js module2.js module3.js
undefinedgit rm module1.js module2.js module3.js
undefinedBad: Direct Deletion
错误操作:直接删除
bash
undefinedbash
undefinedDO NOT USE
禁止使用
rm file.js
rm -rf directory/
unlink file.js
undefinedrm file.js
rm -rf directory/
unlink file.js
undefinedNotes
注意事项
- Files saved to git stash can be recovered later if needed
- Use descriptive reasons in stash messages for future reference
- The stash preserves file contents even after deletion
- List all files in the stash message for clarity
- 保存到git stash的文件可在后续需要时恢复
- 在stash消息中使用描述性的原因,方便日后查阅
- Stash会在删除后保留文件内容
- 在stash消息中列出所有文件以确保清晰
Related Skills
相关技能
- git-operations-rules - General git operation rules (unstage, undo, stash)
- git-operations-rules - Git通用操作规则(取消暂存、撤销、stash)