Sub topic 9
Pulling and committing changes
This chapter assumes you know Git basics (branches, commits, merges) and have a project, a pipeline, a connected development sandbox, and at least one work item. It covers how changes made in a sandbox become commits on a work item branch. It also covers what goes wrong when that step fails.
What the work item branch is
Each work item in DevOps Center has its own Git branch. DevOps Center creates it from the branch of the first pipeline stage when you start work on the item. All commits for that work item go to this branch. Nothing reaches the stage branch until a pull request is merged.
The development sandbox is where you make changes. The branch is where DevOps Center stores them. Pulling and committing is the bridge between the two.
Pulling changes from the sandbox
Pulling reads the list of changes that source tracking has recorded in the development sandbox for that work item. It does not touch Git yet.
- Make your changes in the sandbox, for example a new custom field or an edited Apex class.
- Open the work item in DevOps Center and go to the Changes tab.
- Select Pull Changes. DevOps Center retrieves the list of changed components.
- Wait for the list to finish loading. Large lists can take a while.
The list shows each component's name, type, and whether it was added, changed, or deleted. Only changes made since the last pull or commit appear. If you changed something and it is missing, the cause is usually one of the following:
- The component type is not supported by source tracking.
- The change was made in a different sandbox than the one linked to the work item.
- The change was made in a production org or another environment that does not track changes.
Selecting what to commit
You choose the components to commit. You do not have to commit everything that was pulled.
- Select only components that belong to this work item. Unrelated changes make the pull request harder to review.
- Selecting a component commits its full metadata file, not just your edit. If someone else changed the same file in the sandbox, their edit is included.
- Leave out components you changed by accident, such as a profile that was modified as a side effect.
A good habit is to compare the list with what you meant to change. If it holds more than you expect, find out why before you commit.
Committing
After selecting components, you write a commit message and commit.
- Select the components.
- Select Commit Changes.
- Enter a message that says what changed and why.
- Confirm the commit.
DevOps Center converts the selected components to source format and commits them to the work item branch. The resulting files follow the layout in sfdx-project.json, which is why the project's package directory must match what you track:
{
"packageDirectories": [
{ "path": "force-app", "default": true }
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "62.0"
}A custom field, for example, becomes a file such as force-app/main/default/objects/Account/fields/Region__c.field-meta.xml.
You can commit more than once on the same work item. Several small commits are easier to read than one large one. Each commit appears in the branch history, and the pull request later shows all of them.
Keeping files out of the commit
Some files exist only for local tooling and should never be deployed. A .forceignore file in the repository root tells the tooling to skip them:
# .forceignore
**/jsconfig.json
**/.eslintrc.json
**/__tests__/**
.sfdx
.sfPatterns follow .gitignore syntax. Add entries before you commit. Ignored files are not deployed, but they can still sit in the repository if someone commits them by another route, so keep the file current.
Checking the result in Git
After committing, confirm what landed on the branch. DevOps Center shows the commit, and you can also check in your Git provider or with Git:
git fetch origin
git log --oneline origin/main..origin/UATThat command compares two stage branches. To inspect your own work item branch, replace the branch names with the work item branch and its parent stage branch. The output is the list of commits the branch has that its parent does not, which is what the pull request will contain.
Edge cases and common errors
| Symptom | Likely cause | What to do |
|---|---|---|
| Pull shows no changes | Change made outside the linked sandbox, or unsupported type | Confirm the sandbox and check the metadata coverage list |
| Pull shows many unrelated changes | Other developers share the sandbox | Use a separate sandbox per developer, or select carefully |
| Commit fails with a conflict message | The branch moved since your last pull | Pull again, then resolve the conflict before committing |
| A deleted component is still in the org | The deletion was not committed | Include the deleted item in the selection and commit |
| Profile or permission set contains much more than you changed | Those files hold many settings | Review the diff in the pull request before merging |
| Commit rejected by the Git provider | Branch protection or token permissions | Check the repository rules and the connected account's access |
Deletions
A deletion appears in the pull list like any other change. If you skip it, the component stays in the repository and will stay in every later org. Always check the list for deleted entries.
Shared sandboxes
Source tracking records changes per sandbox, not per person. Two developers in one sandbox see each other's changes in the pull list. Keep one sandbox per developer or per work item stream. If you must share, agree who commits which components.
Staleness
If your work item branch is behind its stage branch, your commit can conflict later. Conflicts are covered in a later chapter. For now, keep work items short, and commit and open the pull request soon after finishing.
Validating before you go on
You can check a change outside DevOps Center before it moves forward. This validation-only deployment runs local tests against a stage's org and changes nothing:
sf org login web --alias uat
sf project deploy start --source-dir force-app --target-org uat --dry-run --test-level RunLocalTestsIf it fails, fix the problem in the sandbox, pull again, and add a new commit.
Exercise
You pulled changes for a work item and the list shows a custom field you changed plus a profile you did not mean to change. What should you do before committing, and why?
Show answer
Deselect the profile, so only the components that belong to the work item are committed. Profile files contain many settings, and committing one adds unrelated changes to the branch and the pull request. If the profile change is needed, keep it and check its diff in the pull request.
Exercise
A teammate says their change is in the shared development sandbox but does not appear in the pull list for your work item. Name two possible causes.
Show answer
The change was made in a different sandbox from the one linked to your work item, or the component type is not supported by source tracking. A change made in a non-tracking environment such as production would also not appear.