Git Workflows
Step-by-step workflows for common development scenarios using SuiteCloud Development Framework (SDF) in VSCode.
Branch Strategy Overview
main ─────●─────────────────────────●───────●─── (Production)
│ │ ↑
│ hotfix/fix │
│ └───────┘
│
↓
develop ──●────●────●────●────●────●────●─────── (Integration)
│ ↑ │ ↑
│ │ │ │
feature/NS-123 bugfix/NS-456
└────┘ └────┘
Branch Types Summary
| Branch Type | Source | Target | Purpose |
|---|---|---|---|
feature/ | develop | develop | New functionality |
bugfix/ | develop | develop | Non-critical fixes |
hotfix/ | main | main → develop | Critical production fixes |
If you're a new employee, start with the New Employee Onboarding guide to set up your development environment first.
After reading this guide, try the SDF + Git Practice Guide for real-world scenarios with two developers collaborating, including conflict creation and resolution exercises.
When to Use PR vs Direct Merge
When to Use Each Approach
| Scenario | Use PR | Use Direct Merge |
|---|---|---|
| Team of 2+ developers | ✅ | |
| Code needs review | ✅ | |
| Complex/critical changes | ✅ | |
| Learning/new team member | ✅ | |
| Solo developer | ✅ | |
| Very small fix (typo, comment) | ✅ | |
| Urgent hotfix (with IT Lead approval) | ✅ | |
| Team policy requires PR | ✅ |
Check with your IT Lead about which approach your team uses. Many teams require PRs for all changes to maintain code quality and history.
Moving Between Branches
Switching branches is a fundamental skill you'll use constantly during development. This section covers the systematic approach to safely navigate between branches.
Basic Branch Switching
# Check which branch you're on
git branch # Shows all local branches, * marks current
# Switch to an existing branch
git checkout develop # Traditional command
git switch develop # Modern alternative (Git 2.23+)
# Switch and create a new branch in one command
git checkout -b feature/NS-123-new-feature
git switch -c feature/NS-123-new-feature # Modern alternative
The Golden Rule: Clean Working Directory
Before switching branches, your working directory should be "clean" (no uncommitted changes). Here's the systematic approach:
Handling Uncommitted Changes
When you have work in progress and need to switch branches, you have three options:
Option 1: Commit Your Changes (Recommended if work is complete)
# Stage and commit your changes
git add .
git commit -m "[NS-XXX] WIP: description of changes"
# Now safe to switch
git checkout other-branch
Option 2: Stash Your Changes (Recommended for temporary switches)
Stashing saves your changes temporarily without committing:
# Save current changes to stash
git stash # Stash with default message
git stash push -m "WIP: feature X" # Stash with descriptive message
# Now safe to switch
git checkout other-branch
# ... do your work on other branch ...
# Return to original branch
git checkout original-branch
# Restore your stashed changes
git stash pop # Apply and remove from stash
# OR
git stash apply # Apply but keep in stash
Useful stash commands:
git stash list # View all stashed changes
git stash show # Preview most recent stash
git stash drop # Delete most recent stash
git stash clear # Delete ALL stashes (careful!)
Option 3: Discard Changes (When changes are not needed)
# Discard changes in specific file
git checkout -- filename.js
# Discard ALL uncommitted changes (DESTRUCTIVE - cannot undo!)
git checkout -- .
# OR
git restore . # Modern alternative
git checkout -- . permanently discards all uncommitted changes. Only use this when you're certain you don't need the changes.
Practical Scenarios
Scenario 1: Quick Context Switch
You're working on a feature but need to quickly check something on develop:
# Save current work
git stash push -m "WIP: vendor invoice form"
# Switch to develop
git checkout develop
# ... review code, check something ...
# Return to feature branch
git checkout feature/NS-123-invoice
# Restore your work
git stash pop
Scenario 2: Urgent Bug While Working on Feature
An urgent bug appears while you're mid-feature:
# Save incomplete feature work
git stash push -m "WIP: halfway through invoice validation"
# Create bugfix branch from develop
git checkout develop
git pull origin develop
git checkout -b bugfix/NS-456-urgent-fix
# ... fix the bug, commit, merge ...
# Return to feature work
git checkout feature/NS-123-invoice
git stash pop
Scenario 3: Forgot to Create Branch Before Starting Work
You started coding on develop but should have created a feature branch:
# You're on develop with uncommitted changes
git status # Verify changes exist
# Create new branch (carries your uncommitted changes with you!)
git checkout -b feature/NS-789-new-work
# Now commit on the correct branch
git add .
git commit -m "[NS-789] Add new functionality"
Quick Reference: Branch Navigation Commands
| Task | Command |
|---|---|
| See current branch | git branch |
| See all branches (including remote) | git branch -a |
| Switch to existing branch | git checkout <branch> |
| Create and switch to new branch | git checkout -b <branch> |
| Stash current changes | git stash |
| Restore stashed changes | git stash pop |
| View stash list | git stash list |
| Discard file changes | git checkout -- <file> |
Best Practices
- Always check
git statusbefore switching - Know what you're leaving behind - Use descriptive stash messages -
git stash push -m "description"helps when you have multiple stashes - Don't leave stashes for too long - Apply or drop them promptly to avoid confusion
- Pull after switching to shared branches - Always
git pullafter switching todevelopormain
# Good habit: pull after switching to shared branches
git checkout develop
git pull origin develop
Feature Development Workflow
When to Use
- Adding new SuiteScript (Suitelet, RESTlet, Map/Reduce, etc.)
- Creating new custom records or fields
- Implementing workflow enhancements
- Building new reports or saved searches
- Any non-urgent development work
Flow Diagram (With PR and Without PR)
Detailed Steps with SDF Commands
Step 1-2: Setup Branch
# Switch to develop and get latest
git checkout develop
git pull origin develop
# Create feature branch
git checkout -b feature/vendor-NS123-new-suitelet
Step 3: VSCode SDF Setup
- Open your SDF project folder in VSCode
- Verify authentication:
- Press
Ctrl+Shift+P→ Type "SuiteCloud: Set Up Account" - Or check terminal:
suitecloud account:setup
- Press
- Verify project configuration:
📁 YourProject/
├── 📄 suitecloud.config.js ← Project config
├── 📁 src/
│ ├── 📁 FileCabinet/
│ │ └── 📁 SuiteScripts/ ← Your scripts here
│ └── 📁 Objects/ ← Custom objects (XML)
└── 📄 manifest.xml ← Deployment manifest
Step 4: Development in VSCode
Creating a new Suitelet:
Ctrl+Shift+P → SuiteCloud: Create SuiteScript
→ Select "Suitelet"
→ Enter filename
→ Script created in FileCabinet/SuiteScripts/
Validating your changes:
Ctrl+Shift+P → SuiteCloud: Validate Project
Common file locations:
| Type | Location |
|---|---|
| SuiteScripts | src/FileCabinet/SuiteScripts/ |
| Custom Records | src/Objects/customrecord_*.xml |
| Custom Fields | src/Objects/customfield_*.xml |
| Workflows | src/Objects/workflow_*.xml |
| Saved Searches | src/Objects/savedsearch_*.xml |
Step 5: Commit Changes
# Stage all changes
git add .
# Commit with ticket reference
git commit -m "[NS-123] Add vendor invoice automation suitelet
- Created vendor_invoice_suitelet.js
- Added custom record for tracking
- Configured deployment"
Step 6: Deploy to Sandbox (Testing)
Ctrl+Shift+P → SuiteCloud: Deploy to Account
→ Select your Sandbox account
→ Wait for deployment to complete
Or via terminal:
suitecloud project:deploy --account SANDBOX_ACCOUNT_ID
Step 6.5: Sync with Develop
Before merging (with or without PR), always sync your branch with the latest develop:
git fetch origin
git merge origin/develop
If you get conflicts during the merge, see Managing Merge Conflicts for step-by-step resolution guide.
PATH A: With Pull Request (Recommended for Teams)
Step 7a-8a: Push and Create PR
# Push branch to GitHub
git push -u origin feature/vendor-NS123-new-suitelet
Then on GitHub:
- Navigate to your repository
- Click "Compare & pull request"
- Set base: develop ← compare: feature/vendor-NS123-new-suitelet
- Fill in the PR template
- Assign reviewers
Step 9a-10a: Review, Merge on GitHub
After approval:
- Click "Squash and merge" (recommended)
- Delete remote feature branch on GitHub
Step 11: Local Cleanup (Both Paths)
# After merge (PR or direct)
git checkout develop
git pull origin develop
# Delete local feature branch
git branch -d feature/vendor-NS123-new-suitelet
PATH B: Without PR (Direct Merge)
Use this path for solo developers or when team policy allows direct merges.
Step 7b: Merge Locally to Develop
# Switch to develop and get latest
git checkout develop
git pull origin develop
# Merge your feature branch into develop
git merge feature/vendor-NS123-new-suitelet
If conflicts occur, resolve them following Managing Merge Conflicts, then continue.
Step 8b: Push Develop to GitHub
# Push the merged develop branch
git push origin develop
Step 11: Local Cleanup (Both Paths)
# Delete local feature branch
git branch -d feature/vendor-NS123-new-suitelet
# Optional: Delete remote feature branch if you pushed it
git push origin --delete feature/vendor-NS123-new-suitelet
Quick Comparison: PR vs Direct Merge
| Step | With PR | Direct Merge |
|---|---|---|
| Push feature branch | git push -u origin feature/... | Not required |
| Create PR | On GitHub | Skip |
| Code Review | Required | Self-review |
| Merge location | On GitHub | Locally |
| Push after merge | Not needed (GitHub did it) | git push origin develop |
Bug Fix Workflow
When to Use
- Fixing non-critical bugs found in develop
- Issues that can wait for next release cycle
- Problems discovered during testing
- Minor corrections to existing functionality
Flow Diagram (With PR and Without PR)
Detailed Steps
Step 1: Document the Bug
Before starting, gather information:
**Bug Report:**
- Ticket: NS-456
- Script: vendor_invoice_suitelet.js
- Error: "Cannot read property 'getValue' of null"
- Steps to reproduce:
1. Open Suitelet
2. Leave vendor field empty
3. Click Submit
- Expected: Validation error message
- Actual: Script crashes
Step 2-3: Create Bugfix Branch
git checkout develop
git pull origin develop
git checkout -b bugfix/vendor-NS456-null-vendor-check
Step 4: Locate Issue in VSCode
Using SuiteScript Debugger:
- Open script file in VSCode
- Set breakpoints on suspicious lines
Ctrl+Shift+P→ "SuiteCloud: Debug SuiteScript"- Trigger the bug scenario
- Inspect variable values
Checking NetSuite Execution Log:
- Go to Customization → Scripting → Script Execution Logs
- Filter by your script
- Look for error stack traces
Step 5: Implement Minimal Fix
// BEFORE (buggy)
const vendorId = record.getValue({ fieldId: 'entity' });
const vendorName = search.lookupFields({
type: 'vendor',
id: vendorId, // Crashes if vendorId is null
columns: ['companyname']
});
// AFTER (fixed)
const vendorId = record.getValue({ fieldId: 'entity' });
if (!vendorId) {
throw error.create({
name: 'MISSING_VENDOR',
message: 'Please select a vendor before submitting.'
});
}
const vendorName = search.lookupFields({
type: 'vendor',
id: vendorId,
columns: ['companyname']
});
Step 6: Test in Sandbox
Ctrl+Shift+P → SuiteCloud: Deploy to Account
→ Select Sandbox
→ Test the fix
→ Verify no side effects
Step 7: Commit Changes
# Commit with clear message
git add .
git commit -m "[NS-456] Fix: Add null check for vendor field
Root cause: Script crashed when vendor field was empty
Fix: Added validation before vendor lookup
Testing: Verified in sandbox, error message now displays correctly"
Step 7.5: Sync with Develop
Before merging (with or without PR), always sync your branch:
git fetch origin
git merge origin/develop
If conflicts occur, your bugfix logic takes priority, but apply it to the new code structure from develop. See Managing Merge Conflicts for detailed examples.
PATH A: With Pull Request (Recommended for Teams)
Step 8a-9a: Push and Create PR
# Push branch to GitHub
git push -u origin bugfix/vendor-NS456-null-vendor-check
Then on GitHub:
- Navigate to your repository
- Click "Compare & pull request"
- Set base: develop ← compare: bugfix/vendor-NS456-null-vendor-check
- Reference the bug ticket number
- Describe the root cause and fix
- Assign reviewers
Step 10a: Review and Merge on GitHub
After approval:
- Click "Squash and merge" (recommended)
- Delete remote bugfix branch on GitHub
PATH B: Without PR (Direct Merge)
Use this path for solo developers or when team policy allows direct merges.
Step 8b: Merge Locally to Develop
# Switch to develop and get latest
git checkout develop
git pull origin develop
# Merge your bugfix branch into develop
git merge bugfix/vendor-NS456-null-vendor-check
Step 9b: Push Develop to GitHub
# Push the merged develop branch
git push origin develop
Step 10: Local Cleanup (Both Paths)
# Delete local bugfix branch
git checkout develop
git pull origin develop
git branch -d bugfix/vendor-NS456-null-vendor-check
# Optional: Delete remote bugfix branch if you pushed it
git push origin --delete bugfix/vendor-NS456-null-vendor-check
Bugfix Best Practices
| Do | Don't |
|---|---|
| Make minimal changes | Refactor unrelated code |
| Document root cause | Just fix symptoms |
| Test regression | Only test the fix |
| Reference ticket number | Use vague commit messages |
Hotfix Workflow
When to Use
- Production is broken for users
- Security vulnerability discovered
- Data corruption occurring
- Financial calculations incorrect
Always notify IT Lead before starting a hotfix!
Flow Diagram (With PR and Without PR)
Direct merge (PATH B) for hotfixes should only be used when:
- IT Lead explicitly approves skipping PR due to extreme urgency
- You are the IT Lead and can self-approve
- Review must still happen (code walkthrough via call/screen share)
Visual: Hotfix Branch Flow
main ────●──────────────●────●─── (Production)
│ │ ↑
│ hotfix/NS999
│ └────┘
↓ │
develop ─●────●──────────────●─── (Integration - synced)
Detailed Steps
Step 1: Notify IT Lead
Before writing any code:
Message/Call IT Lead:
"URGENT: Production issue with [script/feature]
Impact: [describe user impact]
Error: [error message if available]
I'm ready to create a hotfix. Approval to proceed?"
Step 2: Create Hotfix from Main
# IMPORTANT: Branch from main, not develop!
git checkout main
git pull origin main
git checkout -b hotfix/NS999-fix-payment-calculation
Step 3: Implement Emergency Fix
Keep it minimal:
// ONLY fix the immediate issue
// Example: Fixing a calculation error
// BEFORE
const total = subtotal * taxRate; // Wrong formula
// AFTER
const total = subtotal * (1 + taxRate); // Correct formula
// Do NOT also refactor, add features, or "improve" other code
Step 4: Quick Testing
# Deploy to Sandbox first (ALWAYS)
Ctrl+Shift+P → SuiteCloud: Deploy to Account → Sandbox
# Test the specific scenario that was failing
# Do quick regression check on related functionality
Step 5: Commit Changes
git add .
git commit -m "[NS-999] HOTFIX: Correct payment calculation formula
CRITICAL: Payment amounts were being calculated incorrectly
Impact: All payments since [date] affected
Fix: Corrected tax calculation formula
Tested: Verified in sandbox with sample transactions"
PATH A: With Pull Request (Recommended)
Step 6a: Push to GitHub
git push -u origin hotfix/NS999-fix-payment-calculation
Step 7a: Create PR to Main
Create PR on GitHub:
- Base: main ← Compare: hotfix/NS999-fix-payment-calculation
- Title:
[HOTFIX] NS-999: Fix payment calculation - Add "urgent" or "critical" label
- Request IT Lead as reviewer
Step 8a: Emergency Review and Merge
- IT Lead reviews and approves
- Merge using "Squash and merge"
- Do NOT delete branch yet (needed for sync to develop)
PATH B: Without PR (Direct Merge - Emergency Only)
Use this path only when IT Lead explicitly approves skipping PR due to extreme urgency.
Step 6b: Merge Locally to Main
# Switch to main and get latest
git checkout main
git pull origin main
# Merge your hotfix branch into main
git merge hotfix/NS999-fix-payment-calculation
Step 7b: Push Main to GitHub
# Push the merged main branch
git push origin main
Step 9: Deploy to Production
# Deploy to Production account via SDF
Ctrl+Shift+P → SuiteCloud: Deploy to Account → Production
# Or via terminal
suitecloud project:deploy --account PRODUCTION_ACCOUNT_ID
Post-deployment verification:
- Test the fix in production
- Check Script Execution Logs for errors
- Monitor for 15-30 minutes
Step 10: Sync to Develop
# This ensures develop has the fix too
git checkout develop
git pull origin develop
git merge main
git push origin develop
If conflicts occur when syncing to develop, the hotfix code takes priority since it's been tested in production. See Managing Merge Conflicts for resolution strategy.
Step 11: Cleanup and Document
# Delete local and remote hotfix branch
git branch -d hotfix/NS999-fix-payment-calculation
git push origin --delete hotfix/NS999-fix-payment-calculation
Document the incident:
## Hotfix Report - NS-999
**Date:** 2024-01-15
**Severity:** Critical
**Resolution Time:** 45 minutes
**Issue:** Payment calculation formula incorrect
**Root Cause:** Tax rate was multiplied instead of added
**Fix:** Corrected formula in payment_processor.js line 234
**Impact:** ~50 transactions affected, corrections applied
**Lessons Learned:**
- Add unit tests for calculation functions
- Review formulas more carefully in code review
Hotfix Checklist
| Step | Completed |
|---|---|
| IT Lead notified | ☐ |
| Branch from main (not develop) | ☐ |
| Fix is minimal and focused | ☐ |
| Tested in Sandbox | ☐ |
| PR targets main branch | ☐ |
| IT Lead approved | ☐ |
| Deployed to Production | ☐ |
| Verified in Production | ☐ |
| Synced to develop | ☐ |
| Branch deleted | ☐ |
| Incident documented | ☐ |
SDF Project Structure Reference
For all workflows, your SDF project should follow this structure:
📁 MyNetSuiteProject/
├── 📄 suitecloud.config.js # SDF configuration
├── 📄 manifest.xml # Deployment manifest
├── 📁 src/
│ ├── 📁 FileCabinet/
│ │ └── 📁 SuiteScripts/
│ │ ├── 📁 Suitelets/ # Suitelet scripts
│ │ ├── 📁 UserEvents/ # User Event scripts
│ │ ├── 📁 ClientScripts/# Client scripts
│ │ ├── 📁 MapReduce/ # Map/Reduce scripts
│ │ ├── 📁 RESTlets/ # RESTlet scripts
│ │ └── 📁 Libraries/ # Shared libraries
│ ├── 📁 Objects/
│ │ ├── customrecord_*.xml # Custom records
│ │ ├── customfield_*.xml # Custom fields
│ │ ├── workflow_*.xml # Workflows
│ │ └── savedsearch_*.xml # Saved searches
│ └── 📁 Templates/
│ └── *.html # HTML templates
└── 📁 .git/ # Git repository
VSCode SDF Commands Quick Reference
| Action | Command Palette (Ctrl+Shift+P) |
|---|---|
| Set up account | SuiteCloud: Set Up Account |
| Create script | SuiteCloud: Create SuiteScript |
| Import objects | SuiteCloud: Import Objects |
| Validate project | SuiteCloud: Validate Project |
| Deploy to account | SuiteCloud: Deploy to Account |
| Debug script | SuiteCloud: Debug SuiteScript |
Syncing Changes from NetSuite UI
When to Use
Sometimes changes are made directly in NetSuite's web interface:
- Script edited via UI during debugging
- Custom record modified by an admin
- Workflow updated via point-and-click
- Emergency fix applied without SDF
These changes need to be imported and version controlled.
Sync Workflow
Step-by-Step
# 1. Create sync branch
git checkout develop
git pull origin develop
git checkout -b sync/NS-888-import-ui-changes
2. Import Files from NetSuite:
- Press
Ctrl+Shift+P→SuiteCloud: Import Files - Select account → Navigate to script location → Import
3. Import Objects from NetSuite:
- Press
Ctrl+Shift+P→SuiteCloud: Import Objects - Select object type (e.g.,
usereventscript) → Select objects → Import
# 4. Commit and merge
git add .
git commit -m "[NS-888] Sync changes from NetSuite UI
- Imported updated script files
- Imported modified object definitions"
git push origin sync/NS-888-import-ui-changes
# 5. Merge to develop
git checkout develop
git merge sync/NS-888-import-ui-changes
git push origin develop
Discourage direct NetSuite UI edits. Always prefer SDF deployment for proper version control. Use sync branches only when UI changes were unavoidable.
Quick Reference
| Scenario | Branch From | Merge To | Prefix | Urgency |
|---|---|---|---|---|
| New feature | develop | develop | feature/ | Normal |
| Bug fix | develop | develop | bugfix/ | Normal |
| Hotfix | main | main → develop | hotfix/ | Critical |
| UI sync | develop | develop | sync/ | Normal |
Branch Naming
[type]/[team]-[TICKET]-[short-description]
Examples:
feature/vendor-NS123-invoice-automationbugfix/it-NS456-fix-calculationhotfix/NS999-critical-payment-fix
Need Help with Merge Conflicts?
For comprehensive guidance on understanding, resolving, and preventing merge conflicts, see the dedicated Managing Merge Conflicts guide.
Quick tips:
- Don't panic! Conflicts are normal and fixable
- Use VSCode's built-in merge editor for easier resolution
- When in doubt, ask the person who wrote the conflicting code
- See Managing Merge Conflicts for step-by-step resolution