Git Basics for Salesforce Developers
By the end of this lesson, you'll be able to:
- Perform the core Git workflow: branch, commit, push
- Explain why .gitignore matters for a Salesforce DX project
Prerequisites: Source-Driven Development with the CLI
The core loop
The everyday Git loop is: branch (create an isolated line of work), commit (snapshot your changes with a message), and push (send those commits to a shared remote, like GitHub). git status and git diff are the sanity checks you'll run constantly before committing, to see exactly what changed.
.gitignore in an SFDX project
A default Salesforce DX project ships with a .gitignore that excludes local-only files — .sfdx/, .sf/, scratch org auth files, node_modules/ — so you never accidentally commit local CLI state or credentials. Only the force-app metadata source and project config files belong in version control.
Branch, commit, push
git checkout -b feature/opportunity-trigger
git add force-app/main/default/classes/OpportunityTriggerHandler.cls
git commit -m "Add Opportunity trigger handler"
git push origin feature/opportunity-trigger
This is the everyday loop: branch off, stage only the files you actually changed, commit with a clear message, and push the branch for review.
Exercise
Write the Git command to create and switch to a new branch named 'feature/security-course'.
Show hint
git checkout -b <branch-name>
Git Basics for Salesforce Developers — Quick Check
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
Git tracks every change to your local metadata source as commits, letting a team work in parallel on separate branches instead of fighting over one shared org — the same discipline you'd use on any other codebase.