# Usual Command Flows - Daily

This flow represents a typical consultant's daily routine for working with Salesforce scratch orgs and version control.

### 1. Start of Day - Setup

<div class="codehilite" id="bkmrk-bash"><span class="filename">Bash</span></div>```
# Open your terminal/CLI
# Navigate to your project folder
cd path/to/your/salesforce-project

# Get latest changes from repository
git pull origin main

```

**Check for conflicts**: If conflicts occur, resolve them before proceeding or escalate to Technical Architect.

### 2. Salesforce CLI Authentication

<div class="codehilite" id="bkmrk-bash-1"><span class="filename">Bash</span></div>```
# Login to your scratch org
sf org login web --alias my-scratch-org

# Or use existing auth
sf org open --alias my-scratch-org

```

### 3. Deploy Latest Team Changes

<div class="codehilite" id="bkmrk-bash-2"><span class="filename">Bash</span></div>```
# Deploy teammates' latest changes to your scratch org
sf project deploy start --target-org my-scratch-org
```

Review deployed metadata output  
Check for any overlaps with your planned work

### 4. Handle Potential Overlaps

If deployed metadata overlaps with your work:

<div class="codehilite" id="bkmrk-bash-3"><span class="filename">Bash</span></div>```
# Check what changed in git
git log --oneline -n 10
git diff HEAD~1 path/to/file

# If needed, revert specific files to previous version
git checkout HEAD~1 path/to/file
```

### 6. Daily Development Work

<div class="codehilite" id="bkmrk-just-work-in-salesfo"><span class="filename">Just work in Salesforce  
Ideally retrieve once per ticket change (see below)</span></div>### 7. End of Day - Retrieve Changes

<div class="codehilite" id="bkmrk-bash-4"><span class="filename">Bash</span></div>```
# Retrieve metadata changes from your scratch org
sf project retrieve start --target-org my-scratch-org

# Alternative: Retrieve specific metadata types
sf project retrieve start --metadata ApexClass,CustomObject --target-org my-scratch-org

```

### 8. Verify and Commit Changes

<div class="codehilite" id="bkmrk-bash-5"><span class="filename">Bash</span></div>```
# Check retrieved changes
git status
git diff

# Stage specific files (selective commit)
git add force-app/main/default/classes/MyClass.cls
git add force-app/main/default/objects/MyObject__c/

# Commit with ticket number
git commit -m "TICKET-123: Add new validation rule to Account object"

# Push to remote repository
git push origin feature/my-ticket-branch
```

### 9. Handle Merge Conflicts

If merge conflicts occur:

<div class="codehilite" id="bkmrk-bash-6"><span class="filename">Bash</span></div>```
# Attempt to resolve locally
git pull origin main
# Resolve conflicts in your IDE
git add .
git commit -m "TICKET-123: Resolve merge conflicts"
git push
```

**If unable to resolve**: Escalate to Technical Architect or CoE Hub.