The big advantage of Git, as compared to its predecessors, is that it is distributed. It allows many people to access the same project files and each person with granted access sees the full history of versions for each file. It is made for collaboration. To share a repository, it needs to be accessible by some sort of network, for example, the internet. This is where GitHub comes into play.
Assuming that you start a project with the bold goal of visualizing our solar system, you can start coding on your own. You create your own local repository and add and commit the files you want to track in the repository. A few days and many commits later, you realize that this is much too large a task for you to pull off alone. You invite friends to help you. In order to work on the code base together, you upload all your files to GitHub and tie it to your local repository via Git. Git now knows that there is a local repository of your project and a remote repository mirroring the local repository.
Once you have made changes to a file locally and committed them, you can overwrite the same file on the remote GitHub repository by pushing this file up. Your friends can pull the changes you made down to their local machines and see the exact same files you see, including the file with the changes you just made and all changes made previously.