Update documentation - 2025-07-14 16:41
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9552cfbe4e
commit
124336e65f
3 changed files with 55 additions and 9 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -75,4 +75,8 @@ Thumbs.db
|
||||||
|
|
||||||
# IRC bot specific
|
# IRC bot specific
|
||||||
*.pid
|
*.pid
|
||||||
*.lockbackup_bots/
|
*.lock
|
||||||
|
|
||||||
|
# Project specific
|
||||||
|
backup_bots/
|
||||||
|
git_push.log
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,39 @@ Examples of what the script generates:
|
||||||
- **After**: ~20-50 tokens per git operation
|
- **After**: ~20-50 tokens per git operation
|
||||||
- **Savings**: ~75% reduction in git-related token usage
|
- **Savings**: ~75% reduction in git-related token usage
|
||||||
|
|
||||||
## Claude Usage
|
## Claude Usage - TOKEN EFFICIENT WORKFLOW
|
||||||
|
|
||||||
When Claude needs to push changes:
|
**✅ CORRECT (Low Token Usage):**
|
||||||
```
|
```
|
||||||
Please run: ./git_push.sh
|
Please run: ./git_push.sh
|
||||||
```
|
```
|
||||||
|
*Claude ignores output completely*
|
||||||
|
|
||||||
Instead of multiple git commands + output analysis.
|
**❌ AVOID (High Token Usage):**
|
||||||
|
```
|
||||||
|
git status
|
||||||
|
git add .
|
||||||
|
git commit -m "..."
|
||||||
|
git push origin main
|
||||||
|
```
|
||||||
|
*Reading outputs wastes tokens*
|
||||||
|
|
||||||
|
## Logging System
|
||||||
|
|
||||||
|
- All operations logged to `git_push.log`
|
||||||
|
- Only check log if there's an issue
|
||||||
|
- **Claude should NOT read logs unless asked**
|
||||||
|
- Log file ignored by git
|
||||||
|
|
||||||
|
## Error Handling
|
||||||
|
|
||||||
|
If push fails:
|
||||||
|
1. User will see error on console
|
||||||
|
2. User can ask: "Check the git log for errors"
|
||||||
|
3. Only then should Claude read `git_push.log`
|
||||||
|
|
||||||
|
## Token Savings Protocol
|
||||||
|
|
||||||
|
- **Normal operation**: Use script, ignore output
|
||||||
|
- **Only on errors**: Read logs when requested
|
||||||
|
- **Maximum efficiency**: No unnecessary output reading
|
||||||
24
git_push.sh
24
git_push.sh
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
set -e # Exit on any error
|
set -e # Exit on any error
|
||||||
|
|
||||||
|
# Create log file with timestamp
|
||||||
|
LOG_FILE="git_push.log"
|
||||||
|
echo "=== Git Push Log - $(date) ===" >> "$LOG_FILE"
|
||||||
|
|
||||||
# Colors for output
|
# Colors for output
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
BLUE='\033[0;34m'
|
BLUE='\033[0;34m'
|
||||||
|
|
@ -15,12 +19,14 @@ echo -e "${BLUE}🚀 Smart Git Push${NC}"
|
||||||
# Check if we're in a git repo
|
# Check if we're in a git repo
|
||||||
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
||||||
echo -e "${RED}❌ Not in a git repository${NC}"
|
echo -e "${RED}❌ Not in a git repository${NC}"
|
||||||
|
echo "ERROR: Not in a git repository" >> "$LOG_FILE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if there are any changes (including untracked files)
|
# Check if there are any changes (including untracked files)
|
||||||
if git diff --quiet && git diff --staged --quiet && [ -z "$(git ls-files --others --exclude-standard)" ]; then
|
if git diff --quiet && git diff --staged --quiet && [ -z "$(git ls-files --others --exclude-standard)" ]; then
|
||||||
echo -e "${GREEN}✅ No changes to commit${NC}"
|
echo -e "${GREEN}✅ No changes to commit${NC}"
|
||||||
|
echo "INFO: No changes to commit" >> "$LOG_FILE"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -78,20 +84,28 @@ COMMIT_MSG="$COMMIT_MSG
|
||||||
|
|
||||||
Co-Authored-By: Claude <noreply@anthropic.com>"
|
Co-Authored-By: Claude <noreply@anthropic.com>"
|
||||||
|
|
||||||
|
# Log the operation details
|
||||||
|
echo "Files changed: $MODIFIED_FILES" >> "$LOG_FILE"
|
||||||
|
echo "Commit message: $COMMIT_MSG" >> "$LOG_FILE"
|
||||||
|
|
||||||
# Stage all changes
|
# Stage all changes
|
||||||
echo -e "${BLUE}📦 Staging changes...${NC}"
|
echo -e "${BLUE}📦 Staging changes...${NC}"
|
||||||
git add .
|
git add . 2>> "$LOG_FILE"
|
||||||
|
|
||||||
# Commit
|
# Commit
|
||||||
echo -e "${BLUE}💾 Committing: $COMMIT_MSG${NC}"
|
echo -e "${BLUE}💾 Committing...${NC}"
|
||||||
git commit -m "$COMMIT_MSG" > /dev/null
|
git commit -m "$COMMIT_MSG" >> "$LOG_FILE" 2>&1
|
||||||
|
|
||||||
# Push
|
# Push
|
||||||
echo -e "${BLUE}⬆️ Pushing to origin...${NC}"
|
echo -e "${BLUE}⬆️ Pushing to origin...${NC}"
|
||||||
git push origin main > /dev/null 2>&1
|
git push origin main >> "$LOG_FILE" 2>&1
|
||||||
|
|
||||||
echo -e "${GREEN}✅ Successfully pushed to git!${NC}"
|
echo -e "${GREEN}✅ Successfully pushed to git!${NC}"
|
||||||
|
|
||||||
# Show summary (minimal)
|
# Show summary (minimal)
|
||||||
CHANGED_COUNT=$(echo "$MODIFIED_FILES" | wc -l)
|
CHANGED_COUNT=$(echo "$MODIFIED_FILES" | wc -l)
|
||||||
echo -e "${GREEN}📊 Pushed $CHANGED_COUNT file(s)${NC}"
|
echo -e "${GREEN}📊 Pushed $CHANGED_COUNT file(s)${NC}"
|
||||||
|
|
||||||
|
# Log success
|
||||||
|
echo "SUCCESS: Push completed at $(date)" >> "$LOG_FILE"
|
||||||
|
echo "" >> "$LOG_FILE"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue