Imagine a team of 5 developers using DX scratch orgs (using Salesforce' Falcon Template) for working on multiple features in parallel.

They start from a clean packaging org and a clean Git master. Every developer creates a feature branch for her user story and works on it.

  • When do they commit and push?
  • When do they pull?
  • When do they recreate their scratch orgs?

Those are not scratch org questions or on how to version in general. It's about keeping developers in sync and prevent a big merging orgy when everybody is done.

  1. Should everybody pull and recreate and merge as soon as one story is done and merged?
  2. How would that look?
  3. Is the recommended approach documented anywhere?

3 Answers 3


I'm going to have to answer the questions out of order for them to make sense, and much of this is anecdotal at this point, but we've been doing this for a couple of years now, so I hope that this answer will be useful.

Is the recommended approach documented anywhere?

There are several competing theories on which way is the "best," and it's not related just to Salesforce, but any team that deals with git or another version control system. Salesforce only recommends that we use git, but doesn't prescribe a specific pattern, as far as I'm aware.

Should everybody pull and recreate and merge as soon as one story is done and merged?

Depending on the cadence of the team, this is more likely to be disruptive than helpful. There's a fairly simple way to handle this situation, which I'll outline below.

When do they recreate their scratch orgs?

Whenever they feel like it. You can do this one per story, once per feature, every time it expires, etc. Assuming all of the code is in your source of truth, it shouldn't matter.

When do they commit and push?

Commit periodically to have "backups" in case things go wrong, and push (preferably with a "squash") when it's ready to move on to the next branch.

When do they pull?

Immediately before branching or merging.

How would that look?

After a lot of painful experiences, we've come up with this process in general. Starting from the point where there's a new story to be implemented...

The repo should be organized with a master branch, a staging and/or test branch (for deployment to a master testing sandbox), and one branch per story or feature. Start by going to the "dev" branch, whatever that means for your org, pull to make sure you have the latest copy, then create a new branch to work in.

Developers then push the current state of affairs to a Scratch Org, and begin development using their preferred method. Periodically commit so you can fix mistakes if they happen or if your org expires, etc.

Once the story is complete, go back to the "dev" branch, pull again, switch back to the story branch, and merge the dev branch in to the story branch. This brings it up to date and will let you know of any merge conflicts.

Resolve any conflicts, commit again, and then merge/pull request back in to the dev branch. At this point, the dev branch should be good for testing and deployment. Finally, when deploying to production, a similar pull, merge, resolve conflicts (which ideally should not happen), and merge again cycle should happen.

Once everything is fully merged to production, you can delete the story branches to save space and optimize performance.


There are numerous strategies for doing so (So, there is no 1 good answer), however, here are a few resources that can help answers some if not all those questions based on your needs:

GitFlow Examples

These examples are using the default configuration with GitVersion. Which is continuous deployment mode for develop and continuous delivery mode for all other branches.

Feature Branches:

enter image description here

GitHub Flow a nutshell:

  1. Update master to latest upstream code
  2. Create a feature branch git checkout -b myFeatureBranch
  3. Do the feature/work (Spawn Scratch Orgs to develop/test features)
  4. Push feature branch to origin
  5. Create pull request from origin/ -> upstream/master
  6. Review, fix raised comments, merge your PR or even better, get someone else to.

The main rule of GitHub Flow is that master should always be deployable. GitHub Flow allows and encourages continuous delivery.

For a more verbose description of each step, you can refer to Understanding the GitHub flow


Our currently workflow:

  • git checkout -b feature/sales-api
  • git commit add .
  • git commit -am ""
  • git fetch origin
  • git rebase origin master

Once is done, rebase your branch to get the newest version of master, then:

  • sfdx package:version:create....

Actually we have more than one package in a project. Particularly, I don't like this approach, because if I have only one package by repository we could automate everything. Eg. after commit on develop/ build a version and install in the UAT. after commit on master/ build a new version/ update the release doc and install in production.

(Currently we have 35 packages)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .