Short answer
HubSpot's KB: HubSpot matches Salesforce leads and contacts by email. When merging in Salesforce, keep the record currently syncing as primary. Use Salesforce Selective Sync to keep duplicates out.
1. In HubSpot
The relevant screen in my demo portal.

2. Worth knowing
Check which record syncs before any merge.
3. Related
Account sync and sync errors.