Setting up a local repository in VS Code
Confluence: /wiki/spaces/SNGL/pages/2715779242
Resolving merge conflicts
Merge conflict resolution steps
Checkout to the source branch. Make sure to take note of your changes that must be merged and deployed.
Run the Git fetch command.
From the Terminal, run the Git checkout command to copy the contents of a file from the target branch:
git checkout <target_branch> -- <file_path>
git checkout origin/master -- 'force-app\main\default\classes\SampleClass.cls'
The file will now be the same as what is in the target branch, and your changes will be overwritten. Commit and push the staged changes.
Create a pull request, merging the source branch to the target branch. This pull request should not contain your actual changes, and will only contain changes found in the target branch but not in the source branch.
With the file still open, manually add your changes. Commit and push to the remote branch.
Create a second pull request, merging the source branch to the target branch. This pull request will contain your actual changes, but with no more merge conflicts.
Revert a merged commit
Reverting a merge commit
Create a new, temporary branch based from the branch you want to revert a merge commit from, e.g., TAP-1250-RevertFromMaster
based from origin/master
Get the Commit ID of the merge commit you will revert, e.g., 294229cf

Make sure you are checked out to the temporary branch. From Terminal, type command:
git revert <commit id> -m 1
git revert 294229cf -m 1
Commit the changes in the temporary branch, and then publish branch
From the temporary branch, create a pull request to the target branch, e.g., TAP-1250-RevertFromMaster
to origin/master
Once pipelines are successful and PR is approved, merge to target branch
Adding new project to CI/CD pipelines
Confluence: Adding new project to CICD pipelines
Downstream deployments
Downstream deployment process
This process is done after PROD deployments to sync sit
and uat
branches with master
, and uses a “no-commit” branch that is based from master
. Use the branch: ALL-noCommitFromMaster
.
Make sure to rebase the no-commit branch by running a Git pull command:
Push the commits.
Create a pull request for merging ALL-noCommitFromMaster
to sit
, and another pull request to merge the same branch to uat
.
Recording:
Realign and Back Sync.mp4
Rebase Process
Recording: https://unisyd-my.sharepoint.com/:v:/g/personal/bob_alicante_sydney_edu_au/EcZOj_7j9-BMk09Xg2u_D8IBoeJGiE_xYeLxvaKcNbdrLQ?e=V6bscc
Deleting branches
Deleting branches locally and remotely
Using VS Code
Navigate to Git Graph. Make sure to run fetch from remote(s).
Right-click on a branch and select Delete Branch….

If the branch needs to be deleted on the remote, tick both checkboxes. Otherwise, just click on Yes, delete.

Using the Terminal
To delete a branch locally, run the following command:
git branch -d <branch_name>
git branch -D <branch_name>
To delete a branch remotely, run the following command:
git push <remote_branch> -d <branch_name>
Destructive changes
Deleting components in the repository
In VS Code, navigate to Explorer. Right-click on the file and select Delete.

From the Source Control tab, deleting the file will show up as a file deletion under Changes. Follow the same steps as you would for deploying changes: stage the changes, commit and then push to remote.

In Bitbucket, create a pull request to merge the source branch (where the file was deleted locally) to the target branch. Do note that upon merging, the file will be deleted in the target branch, but not on the target environment. Please see the following section: Deleting components in org.
Deleting components in org
As a prerequisite, the target org must be authorized in your VS Code. Please see /wiki/spaces/SNGL/pages/2715779242 for guidance.

In VS Code, create a temporary directory in the project source.

The destructive changes process requires two files: destructiveChanges.xml
and package.xml
. The destructiveChanges.xml
will contain the components for deletion, and the package.xml
must be an empty package file.


From the Terminal, run the following command:
// RECOMMENDED: validate the destructive change first
sfdx force:mdapi:deploy -c -d <folder_name> -l RunLocalTests -w -1
sfdx force:mdapi:deploy -c -d destructiveChangesTAPSS1349 -l RunLocalTests -w -1
// the actual destructive change
sfdx force:mdapi:deploy -d <folder_name> -l RunLocalTests -w -1
sfdx force:mdapi:deploy -d destructiveChangesTAPSS1349 -l RunLocalTests -w -1
This process will initiate a deployment, and thus can be monitored in Setup > Deployment Status.
IMPORTANT: The directory should not be staged as changes and pushed to the branch.
Useful SFDX commands
// validate multiple files using package.xml
sfdx force:source:deploy -c -x manifest/package.xml -l NoTestRun
// validate a single file
sfdx force:source:deploy -c -p 'force-app\main\default\classes\SampleClass.cls' -l NoTestRun
// retrieve multiple files using package.xml
sfdx force:source:retrieve -x manifest/package.xml
// retrieve a single file
sfdx force:source:retrieve -p 'force-app\main\default\classes\SampleClass.cls'