### Choose your licence ###

If your code has been *closed source* up to now, the first thing you should do is decide on which open source license ([GPL <=2, GPL 3][1], [LGPL][2], [BSD][3], [Eclipse][4] etc.) you want to use.

There are pro's and cons to each, so read up on what restrictions they place on the code and decide who you want to be able to use it. *Warning*, whichever you choose someone will complain - this **is** *holy war* territory, and beyond the scope of this question.

* A great resource for determining which license is the right license for you is the very comprehensive, interactive [license differentiator][5], from Oxford Universities [OSS Watch][6].

### Sanitise your repository ###

If the code in your repository doesn't already have your chosen license applied to it, I would go through your entire revision history so far and retroactively apply it (this may require a re-base at every point where a new source file is introduced). This will, however produce a nice clean repository which, when you release it to the public, has no revisions where your chosen licence isn't in force.

Another option is to start your public repository at the point of your first release, with minimal or no history up to that point.

This has the *disadvantage* that people can't go back through your history and work out how you got to where you are today, but it has the *advantage* that people can't go back through your history and work out how you got to where you are today. *8')

When the company I work for made the software I work on open source, we started by only producing snapshots of the working directory at release points. When we move to public on-line repositories we will probably only include history going back to the first public release.

### Consider a Dual License ###

Finally, if you think there might be commercial interest in using your software, but have an ideological preference for a restrictive re-use license such as GPL 3, consider offering dual licensing. Offering GPL 3 licenses for public download, and commercial licenses for a fee gives you the best of both worlds.

Doing this from the outset is likely to cause less friction than starting to offer commercial licenses later on. If your community becomes popular, people may accuse you of selling out if you weren't straight about the possibility of commercial exploitation later. 

[This answer][7] to [this question][8] provides some good information on this option too.

  [1]: http://en.wikipedia.org/wiki/GNU_General_Public_License
  [2]: http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
  [3]: http://en.wikipedia.org/wiki/BSD_licenses
  [4]: http://en.wikipedia.org/wiki/Eclipse_Public_License
  [5]: http://oss.ly/licdif
  [6]: http://www.oss-watch.ac.uk/resources/licdiff.xml
  [7]: http://programmers.stackexchange.com/questions/5225/does-open-source-licensing-my-code-limit-me-later/5228#5228
  [8]: http://programmers.stackexchange.com/q/5225/22493