Short answer. You lose it. Under the Civil Code, if you are the owner of the smaller, accessory thing and you incorporate it into someone else's principal property in bad faith, you forfeit the thing you attached and must also indemnify the owner of the principal property for whatever damages they suffered from what you did.
What the law says
Whenever the owner of the accessory thing has made the incorporation in bad faith, he shall lose the thing incorporated and shall have the obligation to indemnify the owner of the principal thing for the damages he may have suffered.
Civil Code, Article 470 — Bad Faith in Adjunction. Read the full provision →
Losing your own thing is the direct consequence
Article 470 addresses exactly this situation — you own the accessory thing, the smaller or subordinate item, and you attach it to someone else's principal property without permission and knowing you had no right to do so. The consequence is not a fine or a demand to remove it; it is that you lose the thing incorporated outright. The property you attached becomes part of what belongs to the owner of the principal thing, and you have no claim to get it back or be paid for it.
You also owe indemnity on top of the loss
Losing the accessory thing is not the whole consequence — the article separately requires you to indemnify the owner of the principal thing for the damages he may have suffered. That means the other owner is entitled to compensation for whatever harm your unauthorized, bad-faith act caused, over and above simply keeping what you attached. The loss of your property and the duty to pay damages both apply; one does not substitute for the other.
Why 'bad faith' is the pivot point
This harsh result turns specifically on bad faith — attaching your property to someone else's while knowing you had no right to do so, or without a reasonable basis to believe you did. The article treats good-faith incorporation very differently in other parts of the same rule, generally allowing for compensation or a choice between payment and separation rather than outright forfeiture. So whether you acted in genuine good faith or in bad faith is the fact that determines which set of consequences actually applies to what you did.
What to do if you are facing this
If someone is asserting that you incorporated your property into theirs in bad faith, the dispute will likely center on what you knew and when — whether you had a genuine, reasonable belief you were entitled to attach it, or whether you proceeded despite knowing you were not. Gather anything documenting your understanding at the time, and the value of what was attached and any damages being claimed, since those facts will shape both whether bad faith can be shown and how much indemnity might be owed.
A lawyer can help you assess the strength of any good-faith explanation you may have before this is resolved.