4

I'm not sure if the .sfdx folder needs to be tracked by the version control and be pushed to the repo? Can someone please give me some more insight into this folder and its content or even a reference link to a post or official docs explaining this folder and its purpose? I've read a few different posts to understand the SALESFORCE-DX project folder structure but they all focus on force-app and sub-folders and files. I'm leaving the links to some of these posts that are actually very helpful about what they explain.

The following is from the official docs: How to Exclude Source When Syncing or Converting and is about .forceignore file but gives a bit of indication that the .sfdx folder doesn't need to be tracked?

Other Files That the Source Commands Ignore The source commands ignore these files even if they aren’t included in your .forceignore file. Any source file or directory that begins with a “dot”, such as .DS_Store or .sfdx

3 Answers 3

8

You certainly want to gitignore the .sfdx folder. This folder contains information regarding deployment statusses from your computer to your scratch orgs. There is nothing in there that benefits from being source controlled.

The folder contains the orgs folder, which in turn has subfolders for each of your known scratch orgs. The folder name should equal the name of your username for that org. In each org-folder are 2 JSON files; sourcePathInfos.json and metadataTypeInfos.json.

The former (sourcePathInfos.json) contains information regaring each file, most importantly, when you have last changed it, and when it was refreshed most recently. This file is used by SFDX to know which of the files to deploy/refresh.

The latter (metadataTypeInfos.json) is kind of the equivalent of the package.xml file you'd find in classic metadata projects. It contains information on which types of metadata elements should be tracked by this SFDX projects. You'll find entries for Apex Classes, Apex Trigger, LWC, etcetra.

Finally, there's a file called sfdx-config.json, which contains some information on your local settings for this project. In the case of the project I am currently looking at, there's a defaultdevhubusername and a defaultusername, but I am not sure what additional information you might find in there.

2
  • Thanks for the extra information about what it contains. I'd appreciate more details about this folder's content or a link to a post that explains it.
    – Bahman.A
    Commented Nov 12, 2021 at 18:09
  • 1
    I've added some more information, I hope it's of use. Commented Nov 12, 2021 at 18:21
4

The .sfdx folder should never be tracked. In fact syncing would cause a huge issue for rest of the team cloning your project to their local machine, as it may potentially mess up source tracking of their orgs.

Its one of those files which you should never touch and if you do you should be fully aware of what you are doing. Its used internally to help with Source Tracking and tooling.

2
  • Thanks for the extra information about what it contains. I'd appreciate more details about this folder's content or a link to a post that explains it.
    – Bahman.A
    Commented Nov 12, 2021 at 18:10
  • Not that this isn't an awesome answer but since I got my answer from both of you and rael_kid it's hard to pick one as the best so I just picked his since it came through first. Still appreciate the details and cautions you put in your answer. Thanks Mohith.
    – Bahman.A
    Commented Nov 12, 2021 at 18:12
1

I've been looking into the sample repositories of the Trailhead Apps and from these examples it definitely seems that the .sfdx folder doesn't need to be tracked in the repo.

You must log in to answer this question.

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