Any creative work (including software) is automatically protected by copyright. Even when the software is available via code sharing platforms such as GitHub, no one can use it unless they are explicitly granted permission. This is done by adding a software license, which defines the set of rules and conditions for people who want to use the software. Finally, be aware that you, as the developer of a given piece of software, may not be a copyright owner of the code you write. Usually the copyright holder of a work is the employer (or hiring party) and not the author of the work.
We recommend you stick to one of the more popular licenses. Because these are typically written by lawyers, the license text is precise in expressing its terms. While that carries the unfortunate side effect of being difficult to understand, the widespread use of the more popular licenses means that there is a larger number of people who understand how the letter of the law should be interpreted.
Some of our favorite licenses are the Apache-2.0 and MIT licenses. These permissive licenses have very few restrictions, allowing others to easily reuse your work. We recommend you use choosealicense.com to find out which license is best for your purposes. If you just want to check what is and what is not allowed under a given license, visit tldrlegal.com to find out.