Create GitHub repo for your code examples using Windows

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



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 Windows PC 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 Visual Studio. (That’s notable, because your .gitignore file contents will be tuned accordingly.)

Also, for this document, we’re working with ASP.NET projects. An ASP.NET project includes a “packages” folder, with dlls needed for a specific project. This folder is large, about 30MB to 70MB.

So, we will permit a top-level (i.e. ‘root’ directory) “packages” folder, but will ignore each individual project’s “packages” folder. (We don’t want the repository size to balloon needlessly.) When a student downloads a project (or all projects), they’ll simply have to cut/copy-paste the top-level “packages” folder to a specific project. That way, the specific project will build and run successfully.

Also, you must have the GitHub for Windows app installed on your computer. (There’s probably direct Visual Studio 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 BTI420 course:


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. (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 Windows to create a repository

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

Click the “create” button/link near the top 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 “bti420winter2014” folder under the “~/BTI420/Projects/GitHub” folder.

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


Using (Windows) File Explorer, go to (open) the GitHub folder. You will see two files, .gitattributes and .gitignore.

Edit the .gitignore file. Replace its contents with the contents of my .gitignore file found at the URI above.

Next, add LICENSE and files. You can copy them from

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.

Then, copy the project’s “packages” folder and paste it to the repository root, alongside the Week_01 folder etc. At this point, the contents of the “~BTI420/Projects/GitHub/bti420winter2014” folder should include these assets:


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

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.



Uh oh – no packages folder?

You may have to do one more thing.

In GithHub for Windows, click the tools (gear) icon in the upper-right, and choose “open a shell here”.

Type this command in the shell:

git add -f packages

Then, you can exit the shell.

Save/commit, and then sync. Life will be good again.












  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: