FLS not committed for some specific fields.

When moving profiles or permission sets, using either a normal commit or a full profile and permission sets commit, you may notice that the FLS of some fields is not committed into Git.

Whenever this happens, check if the field is required in the source org from where you are committing. If the field is set as required in the field definition, the FLS will not be retrieved by the Metadata API, and therefore it will not be committed. This is the standard behavior as of Metadata API version 30. Please refer to page 339 of the Salesforce document below:

http://resources.docs.salesforce.com/188/latest/en-us/sfdc/pdf/salesforce_spring14_release_notes.pdf

PermissionSet
fieldPermissions for required fields can no longer be retrieved or deployed.


Profile
fieldPermissions for required fields can no longer be retrieved or deployed.


If the field is required in the destination org, the FLS will be already updated in the permission sets and the profiles, as this happens automatically as soon as the field is set as required. If the field is not required in the destination org, you will need to move the field so that the attribute is updated in the target org and the FLS is updated automatically in the profiles and permissions sets.

Another example is the lookup fields like Contact.AccountId or Opportunity.AccountId. The FLS for these fields is not retrieved by the Metadata API and therefore it will not be committed to the feature branch if you select a profile with one of those fields. 

You can log into workbench and use the package.xml below to retrieve the Contact.AccountId or Opportunity.AccountId for a profile. The profile file returned will not contain the FLS for any of these fields.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Contact.AccountId</members>
        <members>
Opportunity.AccountId</members>
        <name>CustomField</name>
    </types>
    <types>
        <members>ProfileName</members>
        <name>Profile</name>
    </types>
    <version>48.0</version>
</Package>

How did we do?