If you're looking at developing software, going the open source route is one of the best ways to do it. Not only can people view your open source code and submit their own fixes, but you are also encouraged to look at other people's code to use as a framework or inspiration.

While going open source might be a good choice, you'll also need to invest in the right community. GitHub is one of the best places to do this, not only because of the sheer amount of users who visit the site, but also because of the features that GitHub offers. If you find an open source app on GitHub, I'll show you a few things you can do with it, including viewing, editing, and forking the code.

Create an Account

Before you get started with using GitHub, it's best to create an account with them. Creating an account is free and will allow you to take advantage of numerous features such as forking. GitHub also has different membership levels besides the free one, but a free account should be more than enough for personal use.

Checking Out a Project

how to view open source code

Once you have an account you can dive straight into an open source application found on GitHub. Here you can see the application's project page, including folders and files pertaining to the application, a network graph, a list of pull requests, open issues, a wiki, and other graphs. Obviously, if you want to see the code within the files, you should click on them and you'll be presented with the full source code. As far as interpreting the code goes, you'll need to have some background in the programming language that the application is written in, whether it be Java, C++, Python, or something else. For those wondering, the screenshot shows Caleb Evan's jcanvas project.

Forking a Project

view open source

Editing the code requires some additional steps. If you wish to copy the code without officially forking it on GitHub, you'll need to download the project's files and then edit them locally on your computer. However, if you're truly looking at using the currently available source and creating your own project with it and going in your own direction, you'll want to fork it. Forking can be accomplished with an account, and by clicking on "Fork" on the project's page as shown in the screenshot. The next few instructions are for Linux users who should install the G

        it
    

package for their respective distribution.

view open source

If you wish to retrieve the repository's files to your computer, you'll need to run the command

        git clone https://github.com/username/project_name.git
    

, replacing username with your GitHub username and project_name with the name of the application project that you just forked. Run this command within a folder that should contain all of your GitHub projects, as each git clone command will create a new folder within the one you're currently residing. This is another way of downloading a project's file as it doesn't require login credentials. Now you can change the files as you please using any text editor or IDE. For Linux users, I'd recommend Eclipse or Geany as they're great programming editors -- Eclipse being more full-featured and Geany being leaner. Windows users can also use the native GitHub client.

Uploading Changes to Your Project

view open source

Once you're done making changes, you can upload the updated files back to GitHub using the command

        git push origin master
    

while inside the application's folder. This pushes the changes back into the "origin" pointer (your forked project) and the master branch (default location of source code).

Keeping Track of Upstream

If you'd like to keep track of the upstream project (the one that you forked to create your own), then you'll need to add what's called an additional remote. This is basically just another keyword you can use while you're inside your application's folder. To create the new remote, run the command

        git remote add upstream https://github.com/username/project_name.git
    

, where username should be replaced by the username of the original project, and project_name should be replaced by its project name.

Merging Upstream Changes

If you notice that the upstream project has been updated and you'd like to incorporate the changes, you can run

        git pull upstream
    

after creating the additional remote, and GitHub will download and merge changes from upstream into your project's files. If everything works perfectly after running that command, you can immediately run

        git push origin master
    

to push the updates to your own project.

Pull Requests

how to view open source code

If you'd like to contribute back to the upstream project, it's best to push any changes to your own fork of the project (or your own branch of the upstream project, but that's only after the original author makes special arrangements). Once you've pushed those changes to your repository, you can go to GitHub and submit a pull request. This notifies the original author of the upstream project that you'd like him/her to review the changes that you've made and have them pull your changes into the upstream project. It's a common courtesy to at least offer some of your own modifications back to the upstream project for them to pull as a thank you for forking their project. Whether they accept your request is up to them.

Conclusion

GitHub is fantastic tool that a large amount of open source developers already use. While GitHub uses the Git utility which anyone can configure on their own servers, GitHub really incorporates the community aspect of development, something that is a requirement in the open source world. This introduction should help you get started with the basics. If you would like to learn more about actual programming, you can check out this article on top sites to brush up on C++.

Have you used GitHub? What feature do you like the most that people should know about? Let us know in the comments!