Create GitHub repo for your code examples using OS X

This note helps you create a GitHub repository to hold your course’s programming code examples, when programming on OS X.



You teach a programming course.

You want to publish code examples. Easily.

Well, a GitHub repository can be a useful tool.



You are using a Mac running OS X to write code.

You have a GitHub account. The “free” account is fine. In that situation, your code will be public. EVERYONE can view it (because it’s on the web).

For this document, we’ll assume that you are using Xcode. (That’s notable, because your .gitignore file contents will be tuned accordingly.)

Also, you must have the GitHub for OS X app installed on your computer. (There’s direct Xcode integration, but I have opted to manage the commit/sync process myself.)


How to organize your code on your computer

You need a folder to hold your projects. For example, I created the following folder for my DPS923 course:

~/Documents/iOS dev projects

In that folder, I create my projects. During a semester, it’s possible to accumulate thirty or forty projects.

My philosophy is to treat the projects in that folder as works-in-progress.

Next, in that folder, I have a GitHub folder. Under that, there is a semester-specific folder, e.g. dps923winter2014. (It gets created by following the steps in the next section.) I treat that as a final ‘published’ destination, that holds a copy of the work-in-progress project. In other words, I don’t actively edit/update the projects in the GitHub folder.

Philosophically, this works for me, because the code examples are just that – code examples.

If I was publishing a project that WAS intended to be a work-in-progress, soliciting student (and public) input, then I would use it as a true GitHub repository, with all its features and benefits.


Then, each week, I create a named folder for the week. Each weekly folder will hold code examples, and a file. For example:




Use GitHub for OS X to create a repository

After installing GitHub for OS X, and configuring it with your account information, you can create a repository.

Click the “create” button (a plus sign) at the bottom of the panel.

Fill in the fields. Take care, and think about what you’re doing. Here’s a sample screen shot:



This will create the “dps923winter2014” folder under the “~/Documents/iOS dev projects/GitHub” folder.

FYI – after publishing to GitHub, the public URI will be:


Using Finder, go to (open) the repo folder.

Create a .gitignore file (using TextEdit, no extension). Its contents will be the contents of my .gitignore file found in a similar repository.

Add LICENSE and files. You can copy them from an existing repo.

Then, add a “Week_01” folder, to hold your week-1 code examples. In that folder, create a file. You can use the contents of any of my weekly “” files as a template if you wish.


What’s with Markdown?

Markdown is the markup language used for various GitHub assets.

Read about it and learn it by using docs provided by the author, John Gruber.


Publishing your first project

Assume that you have finished a project, and are ready to publish it.

Copy the project folder, and paste it into Week_01.

Edit/update the Week_01 “” file with suitable information about the code example(s)  for the students’ benefit.

Open GitHub for OS X. Select the repository. It will show you a list of uncommitted changes.

( need new screen capture images )

Fill in the “Commit Message” in the upper-left area:



Click the “commit to master” button. Next, click the “sync” button in the upper-right area. See the screenshot:



After a few seconds or minutes, your repository is posted to GitHub on the web.














  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: