[SalesForce] Force.com migration tool deployment error with a history Tracking enabled custom object

While I was trying to deploy a copy of source code of production to a developer SB, with the Force.com migration tool, encountered the below error for a custom object with enableHistory = true in the source-source code (this is disabled in the target developer org).

Component Failures:
1. objects/breach__c.object — Error: The entity: breach__c does not have history tracking enabled

Since I do have customObject tag defined correctly in the package xml, I haven't expect something like this.
What am I missing here? what could cause this error?

Thanks in advance.

Best Answer

This is caused by History Tracking being enabled in the source org, but disabled in the target org - or vice versa.

You either need to make them the same in both orgs, or else manually edit the xml to remove the history tracking related tags. If you don't deploy the tags, it won't disable it in the target, it simply deploys the bits you are interested in.

This is an issue we had to tackle at Gearset when building our deployment service. My colleague Luke wrote a blog post https://gearset.com/blog/salesforce-history-tracking-deployment-fix talking about how we address it.