How to incorporate a remote company?

I am from India but recently moved to Berlin, Germany. I want to be flexible with my location as I want to travel in the future and work from anywhere. I should not be required to travel to the country of incorporation for legal purposes etc. 

If you live in Germany your company has to pay taxes there regardless of where it is incorporated. Because of "management and control" rules, the company needs to pay taxes where the real control is.

For now, it would make more sense to set up a sole proprietorship in Germany, and then incorporate a company once you start traveling. Estonia is overall a good option. Singapore is also a good option, but the fees are higher.

I have recently incorporated a UG in Germany, and the process was extremely slow. If you end up going down that route, let me know, as I can show you what not to do. If I were to do it again I would look into incorporating in Ireland - the process is a lot quicker and you don't have to be resident there. But for me I live in Germany and most of my members live in Germany as well, which means the German tax authorities would probably want to tax me there. So for me it was probably still the right option, despite the difficulties.

I will be in Germany temporarily(1-2 years) doing a full-time job. I think incorporating it in Singapore or India (my home country) would be a better option, I think. I am worried about any tax problems in Germany for my side project though.

Right. It might be worth speaking to a Steuerberater (tax-advisor) for advice. I can recommend an English speaking one I used. I paid him €100 for 1 hour and prepared a lot of questions beforehand, so it was definitely worth it.

Another thing you can do is set up a foreign company, and then register a branch in Germany to pay taxes there. When you leave, you close down the branch, and instead bill your customers through the main company. It's quite common to do this.

@fredrik and @bchilakala are spot on. You should typically incorporate in the country where you do most of the work. Also agree on talking to a tax advisor. This is the type of thing you want to do right from the beginning, because changing stuff later is a lot harder and more costly.

Have you considered incorporating as a C-corp in Delaware? I'm from India as well and have incorporated my company in the US through a law firm, although I've heard good things about Stripe Atlas as a way to do it as well. In regards to taxes, usually a US-based CPA can do it for the company since it's a separate entity. If you choose to go this route though, be sure to pay for a good CPA to give your entity a once-over at least since the IRS has a few form requirements with late penalties.

I'm trying now. Will let you know how that goes.

Update: I'm not registering in Germany. I'm using firstbase to register in US.