# Git Workflow Instructions for EP Project

## **Daily Development Workflow**

### **1. Check Current Status**
```bash
git status
```
- Shows which files have been modified, added, or deleted
- Always run this first to see what's changed

### **2. Make Your Changes**
- Edit files in your IDE (like you're doing now)
- Make your fixes, improvements, or new features

### **3. Review What Changed**
```bash
git diff                    # See all changes in detail
git diff filename.php       # See changes in specific file
```
- Review your changes before committing
- Make sure you're happy with what you've done

### **4. Stage Your Changes**
```bash
git add filename.php        # Add specific file
git add .                   # Add all changes
git add -A                  # Add all changes including deletions
```

### **5. Commit with Descriptive Message**
```bash
git commit -m "Brief description of what you fixed/changed"
```
- Write clear, descriptive commit messages
- Examples:
  - `"Fix scorecard generation bug"`
  - `"Add email validation to member form"`
  - `"Update database connection handling"`

### **6. Optional: Push to Remote Repository**
```bash
git push origin master
```
- Only do this if you want to backup to GitHub
- Not always necessary for local development

---

## **How to Restore Files from Previous Changes**

### **Option 1: Undo Uncommitted Changes (Most Common)**
```bash
# Restore a specific file to last committed state
git checkout -- filename.php

# Restore all files to last committed state
git checkout -- .
```
- Use this when you've made changes but haven't committed yet
- **WARNING**: This will permanently delete your uncommitted changes

### **Option 2: Restore from a Specific Commit**
```bash
# First, see your commit history
git log --oneline

# Restore file from specific commit
git checkout <commit-hash> -- filename.php

# Example: Restore from yesterday's fixes
git checkout 29c5a36 -- event-scorecard-setup.php
```

### **Option 3: Restore from a Tagged Version**
```bash
# Restore file from tagged version
git checkout v1.0.0 -- filename.php
```

### **Option 4: See What a File Looked Like Before**
```bash
# See what a file looked like in previous commit
git show <commit-hash>:filename.php

# Compare current file with previous version
git diff <commit-hash> -- filename.php
```

---

## **Quick Reference Commands**

| What you want to do | Command |
|-------------------|---------|
| Check what changed | `git status` |
| See file differences | `git diff filename.php` |
| Add changes | `git add filename.php` |
| Commit changes | `git commit -m "Description"` |
| Undo uncommitted changes | `git checkout -- filename.php` |
| Restore from specific commit | `git checkout <hash> -- filename.php` |
| Restore from tag | `git checkout v1.0.0 -- filename.php` |
| See file history | `git log --oneline filename.php` |
| See all commit history | `git log --oneline` |

---

## **Current Project Status**

### **Recent Commits:**
- `202f7fc` - Clean up repository and add new utility files
- `29c5a36` - Fix issues from yesterday's debugging session  
- `8423616` (tag: v1.0.0) - Consolidate current server state - September 2025

### **Key Files in Project:**
- `event-scorecard-setup.php` - Main scorecard setup
- `event-scorecard.php` - Scorecard generation
- `ephcp.php` - EPHCP functionality
- `event-send-mail.php` - Email functionality
- `event-table.php` - Event table management

---

## **Best Practices**

### **Before Making Changes:**
1. **Always check status first**: `git status`
2. **Make sure you understand what you're changing**
3. **Test your changes** before committing

### **When Committing:**
1. **Commit frequently** - small, focused commits are better
2. **Write clear commit messages** - describe what and why
3. **Review changes** with `git diff` before committing
4. **One logical change per commit**

### **Safety Tips:**
1. **Keep backups** of important files (which you do)
2. **Test changes** before committing
3. **Use descriptive commit messages** - future you will thank you!
4. **Don't commit broken code** - fix it first

---

## **Example Workflow**

Let's say you want to fix a bug in `event-scorecard-setup.php`:

```bash
# 1. Check current status
git status

# 2. Make your changes in the file
# (edit event-scorecard-setup.php in your IDE)

# 3. Review what changed
git diff event-scorecard-setup.php

# 4. If you're happy with changes, add them
git add event-scorecard-setup.php

# 5. Commit with descriptive message
git commit -m "Fix scorecard setup bug in player data handling"

# 6. Check status to confirm
git status
```

---

## **Emergency Recovery**

### **If you accidentally delete a file:**
```bash
git checkout -- filename.php
```

### **If you want to see what a file looked like 3 commits ago:**
```bash
git log --oneline filename.php  # Find the commit hash
git show <commit-hash>:filename.php
```

### **If you want to completely reset to a previous commit:**
```bash
git reset --hard <commit-hash>
```
**WARNING**: This will delete all changes after that commit!

---

## **Getting Help**

- Run `git help <command>` for detailed help on any command
- Use `git status` frequently to understand what's happening
- When in doubt, check the status first!

---

*This document was created to help with Git workflow for the EP project. Keep it handy for reference!*
