Forget protecting intellectual property. Just take a pay check to begin with. Any form of collaboration where you don’t get paid might as well be considered volunteer work. Especially when code is involved, its very easy to remove your details from the script, and very difficult to prove that someone else didn’t arrive at the same implementation to do the same job.
There is nothing wrong with putting your name at the top of a script to indicate who wrote it. But don’t expect the internet at large to pay any attention to your copyright notice.