This question already has an answer here:
So I have been working with Wordpress for almost a year now, almost all of the times i get stuck with the same problem.
When you purchase a hosting you need to give it the domain of the website, now if the domain dont have A record to your host you won't be able to view your website, so you must edit your local hosts file to view it with this domain.
The other option is to work with a sub-domain, which here starts my problem. when you are working with Wordpress it's creating the pages with the Url on the database and than when you finish the website and want to connect to the main domain you need to edit the whole database. (Lets say the wanted domain is xxx.net, and the temp/subdomain is yyy.net)
What are the best ways of moving and connecting the website to the domain after using a sub/temp domain?