Cost information: Free to use for public (open source) repositories. For businesses, $21/user/month provides unlimited private repositories, secure login (SAML single sign-on compatible), and support.
How it works: GitHub acts as a repository for coding projects, allowing for public (and with paid plans private) collaboration, version control, and community troubleshooting. A user publishes their project code either via the web interface or from a Bash shell command line, and a project administrator can solicit feedback and changes, and then either approve or decline suggested changes. GitHub tracks all changes made and suggested, allowing for a project to take several forking paths, and ultimately return to any prior state. Additionally, the service allows for free web hosting of a project through GitHub Pages (github.io).
How could it be useful in a library: Since version control and collaboration is a very hotly requested skill in computer science, any academic library serving a patron base that does any amount of coding will be curious about using Git, whether through GitHub or (as Michele links below!) GitLab or any similar service. Knowing how to use this tool allows for better in-library instruction. Furthermore, any library working on in-house coding projects can garner feedback and collaboration, with a freely-hosted testing site in GitHub Pages for trying changes before publishing them on the library's primary site. I imagine this could be used in an academic or public library system with multiple branches, where a group of people at different facilities are all working on the same coding project.
Types of training required: There's minimal startup training required, with plenty of resources available to get people off the ground using Git and GitHub. Library Carpentry, for one, is a site offering free training for a variety of library-relevant technologies, including Git, SQL, Python, and more, all presented within the context of use in a library.