GitHub is a community site where developers can post their git code repositories. The beauty of Git is its ease-of-use and simplicity and this extends to its online presence. GitHub provides a central location for your git-based code with many additional features. Here’s a look at what GitHub offers, as well as tips on how to use it to host your own code repositories.

Host your code

GitHub allows you to share repositories privately with specific users or publicly with the world to foster collaboration. The public option is free, whereas the private option is not.

I have seen it described as the new resume, as it provides a vehicle for developers to showcase their code as well as involvement in the community. I use it for various client projects, so accessibility to my code repositories is limited, but plenty of companies and individuals post and openly share their code — Facebook is a great example.

GitHub removes the burden of worrying about a server for your source code repository. The git command-line interface makes it easy to create and store repositories on GitHub. Keeping changes synchronized between your local and GitHub-based repositories is quite simple. Let’s take a quick tour through how it is handled. (You must have git set up on your machine and a GitHub account.)

Getting it to work

With git installed on your local machine and a GitHub account set up, you can work locally on the repository and push/pull changes to/from the GitHub-hosted repository. A critical step is assigning the proper email address to your local repository since git and GitHub use your email address to associate commits with an identity; this is accomplished via configuration settings. You can view your current settings for your local repository with the following command.

git config

The email address associated with the repository will be shown. This can be changed by including the email address that should be used.

git config ""

If you have a local repository with committed data/files, you can connect it to a GitHub repository using the remote command.

git remote add remote_name ""

The remote_name is a name assigned to the remote repository. You will use this name in subsequent commands that include pushing and pulling data to and from the remote repository. After setting up the connection with the remote command, you can issue the merge command to merge items from the online repository on GitHub to your local repository. This is often necessary, as the online version may contain a readme file that does not exist in your current repository. As an example, the following command merges items from the master branch with the local files (note, I am in the local repository’s directory).

git merge remote_name/master

If you do not want to merge the data, a pull command can be used to only get items from the online repository. Once the merge is complete, you are synced with the specified branch. At this point, push and pull commands can be used to send changes in the local repository to its online counterpart as well as pull changes down to the local repository. The following command pushes all local changes to the online repository.

git push remote_name

Likewise, the pull command can be used to bring changes from the online repository to your local version. With the pull command, you will need to specify a branch name (if applicable), so the following command pulls all changes from the master branch of the online repository.

git pull remote_name master

The other option for working with GitHub-based repositories is creating a clone. The clone command creates a copy of the online repository on your local machine. This can be accomplished with the command line using the following syntax, which creates a local clone of the Chart.js project.

git clone ""

If you are not a command-line advocate, the GitHub site includes a button to create a local clone (as well as another button to download a zip file containing all project files). It utilizes the GitHub desktop client; the button is shown in Figure A.

Figure A

Easily create a project clone via GitHub.


While the command line is the common way to use git, GitHub provides plenty of point-and-click options as well as the GitHub desktop client. The client is installed on your local machine. It provides a graphic interface to working with GitHub repositories, which includes creating local versions and synchronizing local with online repositories.

Figure B

The GitHub desktop client provides an easy to use interface.

Figure B shows the GitHub Windows client running on a Windows 7 machine. The left side of the interface has links to show local and online (GitHub) repositories. The GitHub listing is highlighted in Figure B, as it shows a list of repositories. Highlighting an individual repository allows you to create a clone as highlighted in Figure B, as well as view its contents as shown in Figure C. The synchronize button at the top right of Figure C provides a simple way to synchronize changes between online and local repositories. The create button (plus sign) at the top of Figure B allows you to quickly create a new GitHub-based repository. The window for creating a new repository is shown in Figure D as you provide a name and path as well as signal if it’s public or private. Click the Push button to finalize the creation.

Figure C

Browse the contents of GitHub repositories with the GitHub client.

Figure D

Create a new GitHub repository via the GitHub client.

We have covered using GitHub for the basics of git and source control, but it is only the tip of the iceberg, as it can be used for all facets of source control including creating forks, collaborating on changes, approving changes, and so forth — all vital aspects of hosting and sharing open source projects via GitHub.

Focus on the project

The widespread popularity and adoption of git along with GitHub provides a simple to use source control system that most developers know how to use. GitHub provides an online location to store and share code with the public or a limited set of users; this allows you to focus on the code and let the folks at GitHub worry about the hosting portion. In addition, version control does not have to be limited to source code, as you can use it to store and host documents, presentations, and so forth.

Do you use GitHub? If so, tell us about your experiences, and let us know if you recommend it to other developers.