This page is for teachers of the AP Computer Science Principles course using CS50. If you’re a student in this course you might also find it useful. If you’ve no connection to the course it probably won’t make a lot of sense. While git is a general tool, the examples and treatment of it herein is really aimed at the course.
Git and GitHub
Git is a tool for managing projects that consist of files. It allows you to keep track of versions of your project, maintain more than one branch of a project, and merge those branches back together. More about these branches later – they are very important to the cs50 management scheme.
GitHub is a web application. It gives you a place to store your projects online, which makes them easy to share and copy. You’ve seen it at least once, when you signed up for a GitHub account that you used to connect with the submit50 tool.
You’re already using Git
Every time one of your students uses the submit50 tool, they are uploading their project to the GitHub website, using the git tool. When you use the cs50.me tool to view the code your students have submitted, you’re also using git and GitHub, though the good folks at cs50 have created a friendly tool for you to do so.
You can do more with Git
On this page I’ll focus on two types of tasks that you can use git to complete in your course. The first is using git to copy student work into your own workspace. The second is using git to share your own projects with students. You can share distribution code for projects of your own creation. At the end I’ll share a tool I wrote for grabbing all your students’ work for a project at once, and I’ll share it with you using GitHub.
How submit50 uses Branches
Branches are a way for a git project to have multiple versions in parallel, rather than sequentially. If you want to try an experimental feature on a project, you might create a branch for that feature. You can keep adding bug fixes to the main branch of your project, while working on the experimental feature separately. If you decide to add the feature to your main project, you can merge that branch into the main branch. When students use the submit50 tool, every one of their projects is a separate branch. This is a clever use of the branch feature of git, but led me to some confusion at first.
Copying Student Work with Git
You can use the git clone tool to copy a student project from submit50 into your own workspace. You’ll need:
- The student’s GitHub username.
- The slug of the problem you want to copy.
You can see both of these in the cs50.me tool. In the video below I show how to copy the project “Fifteen” from a student with GitHub username LSRHS-2-15
The short version: navigate to the directory where you want the student work. Execute this command:
git clone https://github.com/submit50/LSRHS-2-15.git -b cs50/2017/ap/fifteen
The student’s folder will be copied into your current working directory.
Sharing Your Work with Students
For this, you’ll need to create a project. Your project can be any collection of files in a single directory (folder). Its possible to exclude some files in the folder, using a file called .gitignore. In my project, I have a text file of my students’ names that I don’t want to share with you.
This video shows the project I published for teachers to pull their students’ work into their workspace. Give it a try!
https://github.com/sobko/puller
And send me any questions that you have about it.