0

When I retrieve metadata from my sandbox through a package.xml,there are lot of files(Classes, fields, Aura etc) that are shown as modified(M) in my local repository but when I try to check the diff,there are none.Most of the files are same but then how is GIT(or VSCOde) showing the files as modified?

Is somebody else facing this?Changes shown in my VS CODE

2

1 Answer 1

3

When you make a retrieve with mdapi, all files are overwritten, and thus have their file-system's "modification time" audit field updated. To avoid this behavior, use scratch orgs and push/pull instead of deploy/retrieve, and especially avoid any deploy/retrieve with legacy mdapi options (e.g. package.xml). Otherwise, you'll have to diff the files and reset those that haven't actually changed.

3
  • Thanks @sfdcfox. I am using "sfdx force:source:retrieve -x..." command to retrieve from my sandbox.With all the inter-dependencies between metadata,we are still not using scratch orgs for our deployment.Can you please elaborate a little on "and thus have their file-system's "modification time" audit field updated."Is there a way I could check the modified timestamp? Also I have pulled every classes from my org but why it is showing only few classes as "M"(modified)? If everything is overwritten,all classes should be flagged as modified, no?
    – Chetan
    Commented Apr 11, 2020 at 6:44
  • 1
    And just out of curiosity,how and why is the behavior different in "sfdx force:source:pull"?Sorry for inundating with questions but I would like your help to understand them a tad better.
    – Chetan
    Commented Apr 11, 2020 at 6:44
  • 2
    @Chetan Scratch Orgs have a special metadata that tracks changes, so push/pull only updates modified files. There's no guarantee that this happens when you use -x or the mdapi:retrieve command. It looks like they may have optimized some parts (e.g. classes) recently, but generally, if it's in the package.xml, it most likely will be flagged as modified. The modstamp is found in ls -l, dir, or most any file explorer. Also, the autocrlf setting in git may cause some files to be marked as modified (as noted in comments). You should retrieve only files you've modified to avoid issues.
    – sfdcfox
    Commented Apr 11, 2020 at 7:21

You must log in to answer this question.

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