Should the .sfdx or any of its sub-folder and/or files be added to the .gitignore

githubsalesforcedxvscode-dx

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

Best Answer

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.

Related Topic