Skip to content

Repository clean up

Repository clean up

Remove unneeded generated files

Sometimes files are committed to the repository that do not (or no longer) need to be tracked. For example:

  • Files generated by Salesforce when a feature is activated (such as Experience Cloud classes), accidentally added during the first initialization or through a feature branch
  • Overrides of Salesforce classes or files that no longer need patching

If you remove them with the standard process, they are added to manifest/destructiveChanges.xml and deleted from the target org at deployment time, which is not what you want here. One extra step solves this:

  • Follow the standard process: start a User Story (sf hardis:work:new), delete the files, remove them from package.xml, then publish your User Story (sf hardis:work:save) to create your Pull Request (Merge Request on GitLab)
  • Manually edit manifest/destructiveChanges.xml to remove the references to the files you do not want to delete from your target org
  • Commit this change
  • Push to your branch with git (do not run sf hardis:work:save again, it would add the references back)
  • Merge your Pull Request

Comments